C# Modbus communication from entry to proficiency (24) - Modbus TCP (0x03 function code and C# code implementation)

insert image description here

1. 03 (0x03) read holding register

Use this function code to read the value of 1 to 125 holding registers from the remote address, each holding register occupies two bytes, and the number of holding registers to be read is specified by the master station when reading.

2. Send message format

insert image description here

The format of the MBAP header is as follows:
insert image description here

The more detailed format is as follows:
MBAP message header + function code + high start address + low start address + high register quantity + low register quantity, a total of 12 bytes.

3. Return message format

insert image description here

The more detailed format is as follows:
MBAP message header + function code + byte count + high byte of the first register + low byte of the first register + ... + high byte of the value of the Nth register + low byte of the Nth register Bytes, a total of 2*N+9 bytes, N is the number of holding registers that need to be read

4. Case

Slave address: 1
Start address: 0

Guess you like

Origin blog.csdn.net/qq_34059233/article/details/131875386
Recommended