Modbus Exception Codes
Exception Responses
Exception responses from either the client or a server can result from data processing errors. One of the following events can occur after a request from the client:
-
If the server receives the request from the client without a communication error and can handle the request correctly, it returns a normal response.
-
If the server does not receive the request from the client due to a communication error, it does not return a response. The client program eventually processes a timeout condition for the request.
-
If the server receives the request from the client but detects a communication error, it does not return a response. The client program eventually processes a timeout condition for the request.
-
If the server receives the request from the client without a communication error, but cannot handle it (for example, the request is to read a register that does not exist), the server returns an exception response to inform the client of the nature of the error.
Exception Frame
The server sends an exception frame to the client to report an exception response. An exception frame is composed of 4 fields:
Field |
Definition |
Size |
Description |
---|---|---|---|
1 |
Server number |
1 byte |
Destination of the request
|
2 |
Exception function code |
1 byte |
Request function code + 128 (0x80) |
3 |
Exception code |
n bytes |
See next paragraph |
4 |
Check |
2 bytes |
CRC16 (to check transmission errors) |
Exception Codes
The exception response frame has two fields that differentiate it from a normal response frame:
-
The exception function code of the exception response is equal to the function code of the original request plus 128 (0x80).
-
The exception code depends on the communication error that the server encounters.
The following table describes the exception codes handled by the ATSE:
Exception Code |
Name |
Description |
---|---|---|
01 (0x01) |
Illegal function |
The function code received in the request is not an authorized action for the server. The server may be in the wrong state to process a specific request. |
02 (0x02) |
Illegal data address |
The data address received by the server is not an authorized address for the server. |
03 (0x03) |
Illegal data value |
The value in the request data field is not an authorized value for the server. |
04 (0x04) |
Server device failure |
The server fails to perform a requested action because of an unrecoverable error. |