271
ICC
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.
13.1
Ex: Modbus - Profibus
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 105 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 105: Modbus - Profibus Big Endian
In contrast, Figure 106 shows the effects of configuring the database for little-
endian byte order. Holding registers 1 and 2 again have values of 0x1234 and
0x5678, respectively. However, when the Profibus device receiving the input data
from the gateway interprets these values, the resulting pairs of 2-byte values
become 0x3412 and 0x7856, thus receiving incorrect values for holding registers
1 and 2. Note that in both examples, the Profibus network data is always
identical, byte-for-byte, to the gateway’s database. For this reason it is important
to configure gateways that use a bag-of-bytes style network, such as the PBDP-
1000, to use the same endianness as defined for that network.