How to get the error response sent by my flowmeter

17 views
Skip to first unread message

Amine

unread,
Apr 1, 2022, 12:49:43 PM4/1/22
to libmodbus
Hi everyone,

In my flowmeter Modbus documentation, I quote :

<<
If an error is detected in the message received by the unit, the function code in the response is the received function code with the most significant bit set, and the data field will contain the exception code byte, as follows:
Exception Code | Description
01 | Invalid function code — function code not supported by device
02 | Invalid data address — address defined by the start address and number of registers is out of range
03 | Invalid data value — number of registers = 0 or >125 or incorrect data with the Write
Single Coil command

If the first byte of a message is not equal to the unit’s Modbus address, if the unit detects a parity error in any character in the received message (with even or odd parity enabled), or if the message CRC is incorrect, the unit will not respond.
>>

How can I get that exception code in libmodbus knowing that libmodbus only sets "errno" if a function fails to write or read data to/from a Modbus unit.

Thanks.
Reply all
Reply to author
Forward
0 new messages