Function 8: Modbus Diagnostics
Structure of Modbus Messages Concerning PowerTag Link Gateway Diagnostic Counter Management
Request
Definition |
Number of Bytes |
Value |
---|---|---|
Server number |
1 byte |
0xFF |
Function code |
2 bytes |
08 (0x08) |
Sub-function code |
2 bytes |
22 (0x0016) |
Operation code |
2 bytes |
1 ((0x0001) see below list for operation code) |
Diagnostic control |
2 bytes |
0x0100 (see below list for diagnostic control) |
Starting entry index |
1 byte |
0x00 (0 to 255) |
The operation code field is used to select the diagnostic and the statistic data to be read from the device.
Most Significant Byte |
Least Significant Byte |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
Reserved |
Protocol Version |
Operation Code |
Bit assignments are included in the table below:
Bit |
Field |
Description |
---|---|---|
15...12 |
Reserved |
Must be zero |
11...8 |
Protocol Version (PV) |
Indicates version of the protocol of the client (requestor) Values are: 0x00 (initial version) |
7...0 |
Operation Code |
Indicates function to be performed by the command Values are:
|
The diagnostic control field provides the data selection information for this protocol as well as specifies the logical port from which, the data is to be retrieved (if applicable). The diagnostic control field is defined as shown in the following table:
Most Significant Byte |
Least Significant Byte |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
Data Selection Code |
Port Select |
Bit assignments are included in the following table:
Bit |
Field |
Description |
---|---|---|
15...8 |
Data Selection Code (DS) |
Indicates the diagnostic data to retrieve or to clear from the logical port. See the table below for valid values. |
7...0 |
Port Select (PS) |
Indicates the logical port number to retrieve the selected data from
This value should be 0xFF if the requested data is not port specific. See the Port Select Needed column in the table below for which Data Selection Code requires a valid port select value. |
Data selection code
Data Selection Code |
Diagnostic Data Retrieved |
Port Select Needed |
Type |
---|---|---|---|
0x00 |
Reserved |
Public |
|
0x01 |
Basic network diagnostics |
Public |
|
0x02 |
Ethernet port diagnostics |
Yes |
Public |
0x03 |
Modbus TCP port 502 diagnostics |
Public |
|
0x04 |
Modbus TCP port 502 connection table |
Public |
|
0x05 to 0x7E |
Reserved for other public codes |
Public |
|
0x7F |
Data structure offsets |
Public |
|
0x80 to 0xFF |
Reserved |
Reserved |
Response
Definition |
Number of Bytes |
Value |
---|---|---|
Server number |
1 byte |
0xFF |
Function code |
2 bytes |
08 (0x08) |
Sub-function code |
2 bytes |
22 (0x0016) |
Operation code |
2 bytes |
1 ((0x0001) see the above list for operation code) |
Diagnostic control |
2 bytes |
0x0100 (see the above list for diagnostic control) |
Starting entry index |
1 byte |
0x00 (0 to 255) |
Resetting Counters
The counters are reset to 0:
-
When they reach the maximum value 65535.
-
When they are reset by a Modbus command (function code 8, sub-function code 10).
-
When the power is cut off, or
-
When the communication parameters are modified.