Skip to content

Commit

Permalink
Document macros for error codes corresponding to Modbus exceptions (#758
Browse files Browse the repository at this point in the history
)

* Document macros for Modbus error codes
* Add exception response codes to docs

Thank you @kyllingstad
  • Loading branch information
kyllingstad authored Oct 22, 2024
1 parent 5190e5e commit 22ece0f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,21 @@ shall return either a NULL value (if returning a pointer) or a negative value
(if returning an integer), and the actual error code shall be stored in the
`errno` variable.

This includes cases where a Modbus server returns an exception response as a
result of a failed read or write operation. The following macros expand to
integer error codes that correspond to Modbus exception responses:

- `EMBXILFUN`: illegal function (0x01)
- `EMBXILADD`: illegal data address (0x02)
- `EMBXILVAL`: illegal data value (0x03)
- `EMBXSFAIL`: server device failure (0x04)
- `EMBXACK`: acknowledge (0x05)
- `EMBXSBUSY`: server device busy (0x06)
- `EMBXNACK`: negative acknowledge (0x07)
- `EMBXMEMPAR`: memory parity error (0x08)
- `EMBXGPATH`: gateway path unavailable (0x0A)
- `EMBXGTAR`: gateway target device failed to respond (0x0B)

The *modbus_strerror()* function is provided to translate libmodbus-specific
error codes into error message strings; for details refer to
[modbus_strerror](modbus_strerror.md).
Expand Down

0 comments on commit 22ece0f

Please sign in to comment.