Modsak Manual - Tracing and logging
Modsak can trace all raw data that is sent or received, trace each Modbus message that is sent or received, and also log each register read and write. The trace and log output is sent to a separate window (Figure 19, “Trace window”), which can be displayed by selecting the → menu item.
To enable tracing of raw data, select the → checkbox.
If raw tracing is enabled, all data sent or received is displayed as lines in the trace window. Each line begins with the time that the data was sent or received. In monitor mode, the time is followed by 'M' for tracing of data to/from the master, and 'S' for data to/from the slave. This is followed by the character '<' for incoming data or the character '>' for outgoing data, and then the sent or received data in hex.
To enable message tracing, click the Trace button in the main window, or select the → checkbox.
If message tracing is enabled, each Modbus message sent or received is displayed as two lines in the trace window.
The first line begins with the time that the message was sent or received. In monitor mode, the time is followed by 'M' for a message to or from the master, and 'S' for a message to or from the slave. This is followed by the character '<' for an incoming message or the character '>' for an outgoing message. The '<' or '>' is followed by the transaction identifier (only for TCP packets), slave identifier, PDU length (in bytes), function code, and then the first few bytes of the body of the message (in hex).
The second line of a message trace provides an interpretation of the main fields in the message. This line also begins with the time. After the time (and 'M' or 'S' in monitor mode) is the word "Request" for a request message, or "Response" for a normal response message. "Request" or "Response" is followed by the function code (expressed in words) and the main fields of the message (address, count, etc.).
Here is an example of an incoming and an outgoing message:
16:11:20.324: < transid 5 slave 1 pdulen 5 func 3: 00 c8 00 01 16:11:20.325: Request: Read Holding Registers: address 200, count 1 16:11:20.326: > transid 5 slave 1 pdulen 4 func 3: 02 00 00 16:11:20.327: Response: Read Holding Registers: byte count 2, data bytes 2
If the message is an error response, the second line will contain "Error response" followed by the error code (expressed in words), and possibly by further explanation of the error. For example:
16:23:43.186: < transid 10 slave 1 pdulen 5 func 3: 00 64 00 01
16:23:43.188: Request: Read Holding Registers: address 100, count 1
16:23:43.192: > transid 10 slave 1 pdulen 2 func 131: 02
16:23:43.193: Error response: Illegal data address - No Holding Register
at model address 101 (message address 100)
If Modsak receives any data that is not correctly formatted as a Modbus message, it will also trace this data. The data is displayed in hex on a separate line, preceded by the time and the character '<'. This line is followed by a line with the word "Discarded" followed by the number of bytes discarded and an explanation of what is wrong with the format. For example:
15:18:13.554: < 00 01 00 00 00 06 01 03 00 64 02 01 15:18:13.555: Discarded 12 bytes: Invalid CRC
Lines with "Response not sent" following the time may also be displayed in the trace window following a "Request" line. These indicate that Modsak did not send a response to a request from the master - the rest of the line says why the response was not sent. See the Responses setting for more information. For example:
16:19:18.776: < slave 0 pdulen 5 func 6: 00 c8 00 0c 16:19:18.777: Request: Write Single Register: address 200, data bytes 2 16:19:18.778: Response not sent: Request was broadcast
Troubleshooting help is available for the "Error response", "Response not sent" and "Discarded" lines. Click on the line (or move to it with the keyboard and press space) to display the help.
To enable logging of register reads, select the → checkbox.
To enable logging of register writes, select the → checkbox.
If logging is enabled, each read or write of a defined register (see Registers) is logged as a single line in the trace window. Each line begins with the time of the read or write. The time is followed by the character 'R' for a register read or 'W' for a register write. This is followed by the register address and the value read or written. Note that the register address is a "model" address (see Address mapping).
When running in master mode or monitor mode the 'R' and 'W' refer to reads and writes of Modsak's registers, not the slave's registers. So a read command in master mode will cause writes to Modsak's registers, which will be logged with 'W' lines. Similarly, a write command in master mode will cause logging with 'R' lines. In monitor mode, both reads and writes will be logged with 'W' lines.