[issue24859] ctypes.Structure bit order is reversed - counts from right

2015-08-15 Thread eryksun
eryksun added the comment: No, ctypes.Structure should use native endianness. So on a little-endian it's the same as ctypes.LittleEndianStructure, and on a big-endian system it's the same as ctypes.BigEndianStructure. ARM processors can work in either mode. IIRC, the Raspberry Pi is built as

[issue24859] ctypes.Structure bit order is reversed - counts from right

2015-08-15 Thread eryksun
eryksun added the comment: It seems you want a BigEndianStructure: from ctypes import * class SAEJ1939MsgId(BigEndianStructure): _fields_ = (('reserved', c_uint8, 3), ('priority', c_uint8, 3), ('extended_data_page',

[issue24859] ctypes.Structure bit order is reversed - counts from right

2015-08-15 Thread zeero
zeero added the comment: Thanks for the advise. I'll give it a try. So ctypes.Structure is always little endian regardless from the underlying architecture. I just checked on a raspberry pi 2 that should be a big endian device, and got the same results as before. I'm still not sure if it's

[issue24859] ctypes.Structure bit order is reversed - counts from right

2015-08-14 Thread zeero
zeero added the comment: Sorry for the inconvenience. The format specification can be found in chapter 2.1 in http://vector.com/portal/medien/cmc/application_notes/AN-ION-1-3100_Introduction_to_J1939.pdf So I would write down the field contents in that order _fields_ =

[issue24859] ctypes.Structure bit order is reversed - counts from right

2015-08-13 Thread Martin Panter
Martin Panter added the comment: It would be helpful if you could trim down your example code a bit. Without studying the whole file, it is hard to see exactly what order you are seeing and what order you expect, since there are two versions with different orders in the code. My