The block allows to pack unsigned integer values on bit level. The number of bits used for encoding is set by parameter width
, therefore the maximum value of the integer signal that can be encoded is 2^width - 1
. The parameter bitOffset
allows to specify the bit at which the encoding starts relative to the preceding block.
If an AddBoolean
, AddInteger
, AddReal
or AddString
block follows a PackUnsignedInteger
block the bit position after the PackUnsignedInteger
block is aligned to the next byte boundary.
Currently, the pack block only supports Intel-Endianness (little-endian!).
For information about endianness in computing see for example http://en.wikipedia.org/wiki/Endianness
The block is used in example
TestSerialPackagerBitPack_UDP
, depicted below.
AddInteger
block. Assuming that the value of the first Integer variable was 3 (decimal) == 11 (binary)
we would get the memory layout below. A '.' denotes that the bit is not part of the bits encoding the value (LSB = Least Significant Byte and MSB = Most Significant Byte).
byte 24 byte 25 LSB MSB Relative bit position in Memory: (0 1 2 3 4 5 6 7) (8 9 10 11 12 13 14 15) ( .. Value of bit : (0 0 0 0 0 0 1 1) (. . . . . . 0 0)
See also UnpackUnsignedInteger
.