hex array to array of 16 bit numbers?
Bjorn Pettersen
bjorn.pettersen at comcast.net
Thu Dec 25 06:02:19 EST 2003
[posted and mailed]
piir at earthlink.net (Todd Gardner) wrote in
news:9b849915.0312250206.61d89841 at posting.google.com:
> Hello everyone,
>
> I would really appreciate some of your expertise or even just
> pointers. How do I convert this hex array variable "buffer" to array
> of 16 bit numbers?
>
>>>>
>>>> from ctypes import *
>>>> buffer = c_buffer(8)
>>>> status = ni.DAQ_Op (deviceNumber, chan, gain, buffer, count,
> sampleRate)
>>>> print "repr(buffer.raw) =", repr(buffer.raw)
>
> repr(buffer.raw)= '\xcd\x00\xce\x00\xce\x00\xce\x00'
>>>>
>
> Any ideas would be greatly appreciated!
>
> Todd
First I think your missing the fact that the 'hex' values you're seing is
simply an encoding of the byte value at that byte-index in the buffer, ie.
your buffer starts with bytes containing the following values:
[205] [0] [206] ...
besides that, you're looking for the struct module :-)
-- bjorn
More information about the Python-list
mailing list