Tiny Modbus/TCP to RTU/ASCII Gateway
Copyright © 2020 ICP DAS CO., Ltd. All Rights Reserved. - 90 -
Leading 6 bytes of Modbus/TCP protocol:
Length field
(upper byte )
Length field
(lower byte)
Transaction identifier: Assigned by Modbus/TCP master (client)
Protocol identifier: 0
Length field (upper byte): 0 (since all messages are smaller than 256)
Length field (lower byte): Number of following RTU data bytes
RTU Data Structure
Reference number
(Address Mapping)
Net ID (Station Number): specifies the address of the receiver (Modbus/TCP slave).
The first byte in the message structure of Modbus is the receiver’s address. The valid
addresses are in the range of 0 to 247. Addresses 0 is used for broadcast, while addresses 1
to 247 are given to individual Modbus devices.
Function Code: specifies the message type.
The second byte in the frame structure of the Modbus RTU is the function code. The
function code describes what the slave is required to do. Valid function codes are between 1
and 255. The slave uses the same function code as the request to answer it. Only when an
error occurs in the system will the highest bit of the function code is set to ‘1’. Hence the
master will know whether the message has been transmitted correctly or not.