@@ -29,16 +29,16 @@ Following are encoding examples for various field types:
2929
3030* Scalar types::
3131
32- "field_name": uctypes.UINT32 | 0
32+ "field_name": offset | uctypes.UINT32
3333
3434 in other words, value is scalar type identifier ORed with field offset
3535 (in bytes) from the start of the structure.
3636
3737* Recursive structures::
3838
39- "sub": (2 , {
40- "b0": uctypes.UINT8 | 0 ,
41- "b1": uctypes.UINT8 | 1 ,
39+ "sub": (offset , {
40+ "b0": 0 | uctypes.UINT8 ,
41+ "b1": 1 | uctypes.UINT8 ,
4242 })
4343
4444 i.e. value is a 2-tuple, first element of which is offset, and second is
@@ -47,37 +47,37 @@ Following are encoding examples for various field types:
4747
4848* Arrays of primitive types::
4949
50- "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2 ),
50+ "arr": (offset | uctypes.ARRAY, size | uctypes.UINT8),
5151
5252 i.e. value is a 2-tuple, first element of which is ARRAY flag ORed
5353 with offset, and second is scalar element type ORed number of elements
5454 in array.
5555
5656* Arrays of aggregate types::
5757
58- "arr2": (uctypes.ARRAY | 0, 2 , {"b": uctypes.UINT8 | 0 }),
58+ "arr2": (offset | uctypes.ARRAY, size , {"b": 0 | uctypes.UINT8 }),
5959
6060 i.e. value is a 3-tuple, first element of which is ARRAY flag ORed
6161 with offset, second is a number of elements in array, and third is
6262 descriptor of element type.
6363
6464* Pointer to a primitive type::
6565
66- "ptr": (uctypes.PTR | 0 , uctypes.UINT8),
66+ "ptr": (offset | uctypes.PTR , uctypes.UINT8),
6767
6868 i.e. value is a 2-tuple, first element of which is PTR flag ORed
6969 with offset, and second is scalar element type.
7070
7171* Pointer to an aggregate type::
7272
73- "ptr2": (uctypes.PTR | 0 , {"b": uctypes.UINT8 | 0 }),
73+ "ptr2": (offset | uctypes.PTR , {"b": 0 | uctypes.UINT8 }),
7474
7575 i.e. value is a 2-tuple, first element of which is PTR flag ORed
7676 with offset, second is descriptor of type pointed to.
7777
7878* Bitfields::
7979
80- "bitf0": uctypes.BFUINT16 | 0 | 0 << uctypes.BF_POS | 8 << uctypes.BF_LEN,
80+ "bitf0": offset | uctypes.BFUINT16 | lsbit << uctypes.BF_POS | bitsize << uctypes.BF_LEN,
8181
8282 i.e. value is type of scalar value containing given bitfield (typenames are
8383 similar to scalar types, but prefixes with "BF"), ORed with offset for
@@ -91,9 +91,10 @@ Following are encoding examples for various field types:
9191 In the example above, first a UINT16 value will be extracted at offset 0
9292 (this detail may be important when accessing hardware registers, where
9393 particular access size and alignment are required), and then bitfield
94- whose rightmost bit is least-significant bit of this UINT16, and length
95- is 8 bits, will be extracted - effectively, this will access
96- least-significant byte of UINT16.
94+ whose rightmost bit is *lsbit* bit of this UINT16, and length
95+ is *bitsize* bits, will be extracted. For example, if *lsbit* is 0 and
96+ *bitsize* is 8, then effectively it will access least-significant byte
97+ of UINT16.
9798
9899 Note that bitfield operations are independent of target byte endianness,
99100 in particular, example above will access least-significant byte of UINT16
0 commit comments