Hey Mikael,
you mean Modbus worked perfectly, but for example the application layer has a problem? Interesting question.
I've checked the Modbus spec (go to
https://www.modbus.org/ ➡ Technical Resources ➡ Modbus Specifications ➡
MODBUS Protocol Specification) on page 47 (7 MODBUS Exception Responses) and noticed, that a few exception responses are related to the higher layers. For example SERVER DEVICE FAILURE ("An unrecoverable error occurred
while the server was attempting to perform the requested action.").
The SERVER DEVICE FAILURE exception is one of the possible exception codes from the modbus_reply()-fcn (see libmodbus doc ➡ MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE (4)). But, when you search for in in the libmodbus code, then you'll find that it is not really used. Therefore, I would say, that it's not implemented right now.
Best greetings
Sebastian