16-bit signed binary to binary coded decimal(BCD) ascii
Chris Liechti
cliechti at gmx.net
Thu Feb 13 19:22:31 EST 2003
Chris Liechti <cliechti at gmx.net> wrote in
news:Xns9322A89D1BBBcliechtigmxnet at 62.2.16.82:
>> Deirdre Hackett wrote:
>>>
>>> I want to take in data in binary format from a magnetometer.
>>> The magnetometer sends out the x,y,and z components of the magnetic
>>> field. The order of output for the binary format is:
>>> Xhi, Xlo, Yhi, Ylo, Zhi, Zlo.
> maybe he meant something like that:
and this time with signed numbers....
import struct
x,y,z = struct.unpack(">hhh", input_string[:6])
print x,y,z
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list