.Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.UnpackUnsignedInteger

Information

The block allows to unpack unsigned integer values on bit level. The number of bits used for decoding is set by parameter width. The parameter bitOffset allows to specify the bit at which the decoding starts relative to the preceding block.

If an GetBoolean, GetInteger, GetReal or GetString block follows an UnpackUnsignedInteger block the bit position after the UnpackUnsignedInteger 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 deserialized to Real variables. After that two Integer variables are unpacked from the payload. Finally one Integer variable is deserialized using an ordinary GetInteger block. Assume that we had the memory layout below and would like to unpack the second Integer value. 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  byte 26          byte 27                    byte 28
                                                                       LSB                         MSB
Relative bit position in Memory:   0-7      8-15     16-23   (24 25 26 27 28 29 30 31) (32 33 34 35 36 37 38 39) (..
Value of bit                   :                               0  1  .  .  .  .  .  .    0  0  0  0  0  0  0  1

The value of the unpacked second Integer value would be 5 (decimal) == 101 (binary).

See also PackUnsignedInteger.


Generated at 2024-11-21T19:25:40Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos