ModMaster Manual - Tracing and logging

Tracing and logging

Introduction

ModMaster 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 18, “Trace window”), which can be displayed by selecting the ViewTrace menu item.

Raw data tracing

To enable tracing of raw data, select the ActionRaw Trace 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. This is followed by the character '<' for incoming data or the character '>' for outgoing data, and then the sent or received data in hex.

Message tracing

To enable message tracing, click the Trace button in the main window, or select the ActionTrace 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. 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 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 outgoing and an incoming 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). 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

If ModMaster 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

Troubleshooting help is available for the "Error response" and "Discarded" lines. Click on the line (or move to it with the keyboard and press space) to display the help.

Register logging

To enable logging of register reads, select the ActionLog Reads checkbox.

To enable logging of register writes, select the ActionLog Writes 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).

The 'R' and 'W' refer to reads and writes of ModMaster's registers, not the slave's registers. So a read command will cause writes to ModMaster's registers, which will be logged with 'W' lines. Similarly, a write command will cause logging with 'R' lines.

Saving and clearing trace output

The contents of the trace window can be saved to a file by clicking the Save button in the trace window, or by selecting the FileSave Trace menu item.

You can clear the trace output at any time by clicking the Clear button in the trace window.