blob: 7294b7ea45ecd55c7f78bde46db589c02d95c576 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import uctypes
desc = {
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
"arr2": (uctypes.ARRAY | 2, uctypes.INT8 | 2),
}
data = bytearray(b"01234567")
S = uctypes.struct(uctypes.addressof(data), desc, uctypes.LITTLE_ENDIAN)
# Arrays of UINT8 are accessed as bytearrays
print(S.arr)
# But not INT8, because value range is different
print(type(S.arr2))
|