Modbus RTU Exception Codes
Introduction
Revision 4 HC900 Hybrid Controller Communications User Guide 35
9/03
5. Modbus RTU Exception Codes
5.1 Introduction
When a master device sends a query to a slave device it expects a normal response. One of four possible
events can occur from the master’s query:
• Slave device receives the query without a communication error and can handle the query normally.
It returns a normal response.
• Slave does not receive the query due to a communication error.
No response is returned. The master program will eventually process a time-out condition for the
query.
• Slave receives the query but detects a communication error (parity, LRC or CRC).
No response is returned. The master program will eventually process a time-out condition for the
query.
• Slave receives the query without a communication error but cannot handle it (i.e., request is to a non-
existent coil or register).
The slave will return with an exception response informing the master of the nature of the error (Illegal
Data Address.)
The exception response message has two fields that differentiate it from a normal response:
Function Code Field:
In a normal response, the slave echoes the function code of the original query in the function code field of
the response. All function codes have a most-significant bit (MSB) of 0 (their values are below 80 hex). In
an exception response, the slave sets the MSB of the function code to 1. This makes the function code
value in an exception response exactly 80 hex higher than the value would be for a normal response.
With the function code’s MSB set, the master’s application program can recognize the exception response
and can examine the data field for the exception code.
Data Field:
In a normal response, the slave may return data or statistics in the data field. In an exception response, the
slave returns an exception code in the data field. This defines the slave condition that caused the exception.
Query
Example:
Internal slave error reading 2 registers starting at address 1820h from the controller at slave
address 01.
TCP: 00 03 18 20 00 02
RTU: 01 03 18 20 00 02 CRC CRC
Response
Example:
Return MSB in Function Code byte set with Slave Device Failure (04) in the data field.
TCP: 00 83 04
RTU: 01 83 04 CRC CRC