.Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.PackUnsignedInteger

Information

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.

Endianness

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

Example

The block is used in example TestSerialPackagerBitPack_UDP, depicted below.

The first 3*8 byte of the payload is used for the Real variables. After that two Integer variables are packed into the payload. Finally one Integer variable is added using an ordinary 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.


Generated at 2024-03-28T19:15:55Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos