ASCII characters in my hex output

N

nuvodido

I am using pyserial to work with a device on my serial port. the
output is a mixture of ASCII and hex:

Ex. '\x10\x00*'


I need conver the \x00* nuber in to decimal. Is there way to
convter this value striat forward?


Thanks in advance
Kelia Nichols
______________________________________
No trees were killed in the sending of this message. However a large
number of electrons were terribly inconvenienced.
 
F

Francis Avila

nuvodido wrote in message ...
I am using pyserial to work with a device on my serial port. the
output is a mixture of ASCII and hex:

Ex. '\x10\x00*'


I need conver the \x00* nuber in to decimal. Is there way to
convter this value striat forward?

You're not being specific enough. Here are some things to look at:

Pyserial for your serial port-ing needs.

Struct module for C-structs. Array module for homogenous binary data.

Have a look also at ctypes and xstruct (both external modules).

chr() and ord() builtins; shift and binary arithmetic operators.

I suspect what you are asking is something like:

struct.unpack('=bh', '\x10\x00*') -> (16, 10752)

But again, how can I know?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top