From 22ece0fc52865ec37b59748b9d5a68d529aa32d8 Mon Sep 17 00:00:00 2001 From: "Lars T. Kyllingstad" Date: Tue, 22 Oct 2024 14:11:42 +0200 Subject: [PATCH] Document macros for error codes corresponding to Modbus exceptions (#758) * Document macros for Modbus error codes * Add exception response codes to docs Thank you @kyllingstad --- docs/index.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/index.md b/docs/index.md index 47f728ed..4e692364 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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).