hex array to array of 16 bit numbers?
bjorn.pettersen at comcast.net
Thu Dec 25 12:02:19 CET 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,
>>>> print "repr(buffer.raw) =", repr(buffer.raw)
> repr(buffer.raw)= '\xcd\x00\xce\x00\xce\x00\xce\x00'
> Any ideas would be greatly appreciated!
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:
   ...
besides that, you're looking for the struct module :-)
More information about the Python-list