|
AEM
|
Data Structures | |
| class | CommsMgr |
| class | ReadInputThread |
| class | SerialServer |
Functions | |
| def | packNbytes (bytes) |
| def | unpackStruct (format, packed) |
| def | grouper (iterable, n, fillvalue=None) |
Variables | |
| int | pollDisplayIterations = 2000000 |
| for debugging, will display a heartbeat message after this number of polls More... | |
| def commsMgr.grouper | ( | iterable, | |
| n, | |||
fillvalue = None |
|||
| ) |
| def commsMgr.packNbytes | ( | bytes | ) |
This will return a pack of unsigned bytes, suitable for unpacking into their original values. the argument: bytes : is a list of any length of unsigned byte values. [255, 0, 1, ...] returns packed bytes of the form: >>> packNbytes(sss) b'\x01\n\x00\x00\x00\x00\x00\xc0?'
| def commsMgr.unpackStruct | ( | format, | |
| packed | |||
| ) |
This will return a list of values
after unpacking the packed bytes.
Some formats:
b/B : signed/unsigned byte 1
h/H : signed/unsigned short int 2
i/I : signed/unsigned int 4
f : float 4
d : double 8
size and byte order:
find the system byteorder by examining
sys.byteorder
on Intel and RPI it is 'little'
@ native order native size, native alignment (needs examination)
= native order, standard size, no alignment
</> little/big endian, standard size, no alignment
! big endian, standard size, no alignment
the correct choice is '<' to get little endian, which is what is needed
for Arduino and RPI and PC/Intel
Will return a list of things corresponding to format spec.
Ex:
if we have an unsigned byte, unsigned long, float = 9bytes
>>> unpack('<BIf' packNbytes([<9 numbers that are on [0,255]])
[uint8_t, uint32_t, f]
| int commsMgr.pollDisplayIterations = 2000000 |
for debugging, will display a heartbeat message after this number of polls