The Modbus debugging tool tests whether a gateway can connect to a specified Modbus device and whether the Thing Specification Language (TSL) model of the product to which the Modbus device belongs is correctly configured.
Prerequisites
- An edge instance is created. For more information, see Set up environments.
- A Modbus driver and a sub-device are assigned to the edge instance. For more information, see Modbus drivers.
Procedure
- Log on to the Link IoT Edge console.
- In the left-side navigation pane, click Edge Instances. Find the instance to which the Modbus device is assigned and click View in the Actions column.
- On the Instance Details page, click the Devices & Drivers tab. In the All Drivers section, click the Modbus driver. Then, find the device that you want to debug and click Debug in the Actions column. Note If the Debug button is dimmed, click Reset in the upper-right corner of the Instance Details page and reset the edge instance.

- On the Channel Debugging page, click Add Property and debug the configurations.
- The following table describes the coil parameters.

Table 1. Description of coil parameters Parameter Description Address The IP address of the coil. The IP address must be in the hexadecimal format and start with 0x.You must specify the IP address of the coil based on your device property. For example, if the device temperature is indicated by 1 in the IP address, you can set this parameter to
0x1.Property Name The name of the property. Set the property names and save the configurations. On the Define Feature tab of the Product Details page, you can view the property names in the Feature Name column by selecting the Self-Defined Features filter.
Read Function Code The function code that is used to perform a read operation on the coil or specify the status of the coil. Write Function Code The function code that is used to perform a write operation on the coil. Note If the Read Function Code parameter is set to0x02, you cannot perform write operations. A value of 0x02 indicates an input state.Current Value The measured value of the property in the TSL model of the product to which the Modbus device belongs. For example, the current value can be the illuminance, temperature, or humidity that is measured. Actions - Read: sends the command to the gateway to read the measured value. The gateway sends a read command to the device and returns the result to the Current Value column.
- Write: sends the command to the gateway to write the measured value. The gateway sends a write command to the device and updates the Current Value column. Note If the Read Function Code parameter is set to
0x02, you cannot perform write operations. A value of 0x02 indicates an input state. - Delete: deletes the coil from the TSL model of the product to which the device belongs. Important After you delete the coil and save the configurations, all devices of the product are affected.
- The following table describes the register parameters.

Table 2. Description of register parameters Parameter Description Address The starting IP address of the property. The IP address must be in the hexadecimal format and start with 0x.Important When you add multiple register IP addresses, the IP addresses cannot overlap. If the IP addresses overlap, an error occurs when you save the configurations.You must specify the IP address of the register based on your device property. For example, if the device temperature is indicated by 1 in the IP address, you can set this parameter to
0x1.Property Name The name of the property. Read Function Code The function code that is used to perform a read operation on the register. Write Function Code The function code that is used to perform a write operation on the register. Note- If the Read Function Code parameter is set to
0x04, you cannot perform write operations. A value of 0x04 indicates an input register. - If you want to write data of types other than INT16 and UINT16 to the holding register, set this parameter to
0x10.
Data Type The data type of the register. Valid values: int16, uint16, int32, uint32, int64, uint64, float, and double. Different data types use different numbers of registers. For more information, see Number of registers of each data type. Unit The unit of the measured value for the property of the Modbus device. Current Value The measured value of the property in the TSL model of the product to which the Modbus device belongs. For example, the current value can be the illuminance, temperature, or humidity that is measured. Actions - Read: sends the command to the gateway to read the measured value. The gateway sends a read command to the device and returns the result to the Current Value column.
- Write: sends the command to the gateway to write the measured value in the decimal format. The gateway sends a write command to the device and updates the Current Value column. Note If the Read Function Code parameter is set to
0x04, you cannot perform write operations. A value of 0x04 indicates an input register. - Advanced: configures more register parameters. For more information, see Description of advanced parameters.
- Delete: deletes the register from the TSL model of the product to which the device belongs. Important After you delete the register and save the configurations, all devices of the product are affected.
Table 3. Description of advanced parameters Parameter Description Swap Bytes Controls the byte order that is used to parse the register information. By default, the big-endian ordering is used. Valid values: - true: The little-endian ordering is used.
- false: The big-endian ordering is used.
Example 1: When 12345 is written, the corresponding hexadecimal value is 0x3039. If this parameter is set to false, the byte order for sending and receiving the value is 30 39. If this parameter is set to true, the order is 39 30.
Example 2: Assume that you use the 0x10 function code to send the RTU message for writing data to the holding register of a Modbus device whose station number is 1. If this parameter is set to false, the complete message is 01 10 02 00 01 30 39 F7 E1. If this parameter is set to true, the message is 01 10 02 00 01 39 30 33 14.
Swap Registers Controls the order in which the registers are parsed. The data type must be INT16 or UINT16. By default, the system treats the registers of lower addresses as the ones that have higher bit values. Therefore, higher bit values are sent first and the registers of lower addresses are parsed first. Assume that the Swap Bytes parameter is set to false and you send INT64 data, which is 0x1234567890ABCDEF, to the device. The data is split into four registers. In this case, if this parameter is set to false, the ordering of the message is 12 34 56 78 90 AB CD EF. If this parameter is set to true, the ordering of the message is CD EF 90 AB 56 78 12 34.
Zoom Factor Sets how the raw data of the device is scaled. When the performance of floating-point operations is poor, you can set the floating points to integers. This parameter allows you to set a factor to scale the raw data of the device. For example, when the device uses 1234 to represent 12.34, the scale factor must be set to 0.01. All data values that are set for the device are automatically multiplied by 100 and sent to the device. When the 12.34 value is set on the cloud or in the console, the driver automatically converts 12.34 to 1234 and sends the result to the device. Conversely, when the device sends messages, 1234 is converted to 12.34 before it is sent to IoT Platform or other devices.
Table 4. Number of registers of each data type Data type Number of registers Description int16 1 The 16-bit signed integer type. uint16 1 The 16-bit unsigned integer type. int32 2 The 32-bit signed integer type. uint32 2 The 32-bit unsigned integer type. int64 4 The 64-bit signed integer type. uint64 4 The 64-bit unsigned integer type. float 2 The single-precision floating-point type (32 bits). double 4 The double-precision floating-point type (64 bits). - If the Read Function Code parameter is set to
- The following table describes the coil parameters.
- After the debugging is complete, click Save Configurations to update the features of the product to the server. The Saved message appears, which indicates that the data is saved to the server.Note After the configurations are saved, a custom feature is generated. On the Define Feature tab of the Product Details page, you can view the feature by selecting the Self-Defined Features filter for the Feature Name column. The value in the Identifier column is automatically generated by the system after the configurations are saved. The identifier is generated based on the following principles:
The value in the Identifier column is based on the value of the Identifier parameter in the TSL model of the device. The value of the Identifier parameter is in the
Register type_4-bit hexadecimal addressformat. For example, if the Read Function Code parameter in the configurations is set to 01, the register type is coilStatus, the address is set to 0x00, and the 4-bit hexadecimal address is 0000, the value of the Identifier parameter is coilStatus_0000.
Other operations
- Reset: On the Channel Debugging page, you can click Reset in the lower-left corner to reset the current configurations.
- Channel Configurations: On the Channel Debugging page, you can click Channel Configurations in the upper-right corner to modify the parameters of the Modbus communication channel. Then, click OK to save the changes.
- Log Debugging: On the Channel Debugging page, you can click the Log Debugging tab to view the debugging logs. You can also click Clear Screen to clear the logs on this tab.
Function codes for different register and coil types
| Type | Function code | Operation type |
| Coil (coil status) | 0x01 | coilState |
| Input state (input coil) | 0x02 | inputState |
| Holding register | 0x03 | holdingRegister |
| Input register | 0x04 | inputRegister |