40
ICC
simply stored into the database in the order they were received. Gateway
endianness selection therefore has no effect on data storage or retrieval with a
“bag of bytes” protocol driver.
The other method is that used by networks that exchange data by means of an
“object value” system, whereas data is exchanged by addressing a certain object
to read or write data. Modbus for example, uses registers, while BACnet uses
objects such as analog values to exchange data. When multi-byte values are
received by the gateway, the bytes must be stored into the database in the order
defined by the endianness selected. Likewise, when retrieving multi-byte values
from the database for the gateway to transmit, the endianness selected will
determine how the data is reconstructed when read from the database.
The selection of the correct byte ordering is crucial for coherent interaction
between these two types of networks on the gateway. The following presents
examples of how the database endianness affects end-to-end communication
between networks and when each byte-ordering scheme should be used.
11.1
Modbus - PROFIBUS Example
This example shows the interaction between a network using an object value
method (Modbus) and one using a bag of bytes method (PROFIBUS) to
exchange data. The gateway reads holding registers 1 and 2 from the Modbus
network, stores the data into the database, and then sends the 4 bytes of input
data onto the PROFIBUS network. Figure 14 shows this data movement for the
gateway’s database configured as big endian. Because the PROFIBUS
specification defines multi-byte values within the byte array to be interpreted as
big endian, it is recommended that the database be configured for big-endian
byte order when using PROFIBUS. In the example, holding register 1 has a value
of 0x1234 and holding register 2 has a value of 0x5678. When the PROFIBUS
device receiving the input data from the gateway recombines the two pairs of 2-
byte values, the resulting data is 0x1234 and 0x5678, thus successfully receiving
the correct values for holding registers 1 and 2.
Figure 14: Modbus - PROFIBUS Big Endian