Page 39 of 47
Modbus TCP frame format:
MBAP Header:
7 bytes, Modbus application protocol header. used to identify the modbus
frame transmitted on the TCP/IP stack.
Function Code:
1 bytes, coding range 1-255
Data:
N*1 bytes, based on the types of the function code.
MBAP Header:
Transaction ID:
2 bytes, Modbus request/respond transaction identifier.
Protocol ID:
2 bytes,0=Modbus protocol
Length:
follow-up bytes, include Unit ID and data field
Unit ID:
1 bytes, the ID of remote slave station
Example 1:
Modbus TCP(Data Center send to modem):
00 01 00 00 00 06 01 04 00 00 00 01 (06 length, 01 is modbus address, 04 is function code, 00 00
00 01 is the register start address 2 bytes + the number of registers 2 bytes)
Modbus RTU(recieve in serial port of modem):
01 04 00 00 00 01
31 CA
(
31 CA is CRC code
)
Response data from serial:
01 04 02 00 B8
B9 42
(
02 is length
,
00 B8 is data
)
Data center will recieve modbus TCP data:
00 01 00 00 00 05 01 04 02 00 B8 (05 is data length)
Example 2:
Data center send
:
00 01 00 00 00 06 01 04
00 08 00 01
Dispaly in serial
:
01 04
00 08 00 01
B0 08
Response in serial
:
01 04 04 00 08 00 B8 7A 34
Data center recieve
:
00 01 00 00 00 07
01 04 04 00 08 00 B8
The communication test as the below picture: