Share this

Introduction to Serial Communication/Debugging Code

2026-04-06 06:08:44 · · #1

When remote I/O devices implement Modbus communication, they all act as slave devices, follow the Modbus communication process, and adopt a subset of commands of the MODBUS-RTU protocol, using the read register command (03) and the single register set command (06). There is at least a 3.5-byte time interval between the beginning and end of each message.

Note:

Command 03 is used by the host to read the collected data or port status of remote I/O devices;

Command 06 is used to set device parameters or remotely control the operation of I/O device relays;

Function code 03 (Read instruction)

The device's values ​​are read using the Modbus communication protocol's 03 function code.

Host request data format: Slave address, function code, starting address, number of data items and CRC code

For example: If the slave address is 01, read the value (1 value) from device register address = 0000.

Slave response data format: slave address, function code, number of bytes, data area, and CRC code.

Register data is two bytes, with the most significant byte first. CRC codes are also two bytes, with the least significant byte first.

For example: If the slave address is 01, the following will be returned:

010302DATA0HDATA0LCRCLCRCH

Function code 06 (Write command)

Use the 06 function code of the Modbus communication protocol to set the value of a register in the device.

Master request data format: slave address, function code, register address, set data, and CRC code.

Common command examples

The device's serial port factory parameters are as follows:

You can search online for "CRC online calculator" to calculate the CRC value.

The following example uses device address 485 as 1:

1) Read the contents of all device registers: 0001 to 0016, a total of 22 registers, each register containing 2 bytes.

The host computer sends: 01, 03, 00, 01, 00, 16, 95, C4

The slave device returned: 01, 03, 2C, (44 bytes of data), CRCL, CRCH

2) Read 485 address (03 read instruction)

The host computer sends: 01, 03, 00, 01, 00, 01, D5, CA

Slave device returned: 01, 03, 02, 00, 01, 79, 84 (address 1)

3) Set address 485 (write instruction 06)

The host computer sends: 00, 06, 00, 01, 00, 01, 18, 1B (sets the address to 1).

Slave device returns: 01, 06, 00, 01, 00, 01, 19, CA

Disclaimer: This article is a reprint. If there are any copyright issues, please contact us promptly for deletion (QQ: 2737591964). We apologize for any inconvenience.

Read next

CATDOLL 146CM Ya TPE (Customer Photos)

Height: 146cm A-cup Weight: 26kg Shoulder Width: 32cm Bust/Waist/Hip: 64/54/74cm Oral Depth: 3-5cm Vaginal Depth: 3-15c...

Articles 2026-02-22
CATDOLL 148CM Hanako TPE

CATDOLL 148CM Hanako TPE

Articles
2026-02-22
CATDOLL 130CM Sasha

CATDOLL 130CM Sasha

Articles
2026-02-22
CATDOLL 136CM Seina

CATDOLL 136CM Seina

Articles
2026-02-22