ASCII characters in my hex output
Francis Avila
francisgavila at yahoo.com
Mon Jan 5 16:33:17 EST 2004
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?
--
Francis Avila
More information about the Python-list
mailing list