libmodbus icon indicating copy to clipboard operation
libmodbus copied to clipboard

Missing documentation of `errno` values corresponding to Modbus exception codes

Open kyllingstad opened this issue 1 year ago • 2 comments

libmodbus version

e6b71a88866b86c1cb66c2dafa5a08e6b87ad596 (which is the tip of master at the time of writing)

Description

The libmodbus documentation does not specify how one can obtain information about Modbus exception codes returned by a server upon a failed read or write operation.

Actual behavior if applicable

By reading the source code, I've discovered that libmodbus does in fact set errno to codes corresponding to the Modbus exception codes, such as EMBXILFUN etc. However, as far as I can tell, this is not mentioned anywhere in the reference documentation. For example, the reference page for modbus_read_registers() lists EMBMDATA as the only error code (which is an internal libmodbus error and not a Modbus exception).

Expected behavior or suggestion

Ideally, each function reference page should list all possible errno values, or at least the non-standard ones.

At minimum, the Error handling section of the front page should describe in general terms how Modbus exception codes are handled, what the corresponding constants are called, and which functions may return them.

kyllingstad avatar Jan 05 '24 07:01 kyllingstad

I'd be happy to draft the minimal description I suggested at the end and submit a PR if this is desirable.

kyllingstad avatar Jan 05 '24 07:01 kyllingstad

Yes please!

stephane avatar Jul 17 '24 10:07 stephane