scenario: modbus_reply() works, but the rest of the server doesn't?

24 views
Skip to first unread message

Mikael Jakas

unread,
Nov 23, 2021, 7:53:51 AM11/23/21
to libmodbus
Hi,
The following situation: a TCP libmodbus server receives a write request. Things work fine and the modbus_reply() function does it's job (updates the mapping and sends a response).

Then, the data in the mapping is used for further work in the server. Lets assume this fails. Is the correct action at this point to simply send an exception? I.e. first there is a positive reply possibly followed by for example a Server Device Failure Exception message.


regards,
-MJ

Sebastian Psm

unread,
Dec 14, 2021, 3:14:42 AM12/14/21
to libmodbus
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
Reply all
Reply to author
Forward
0 new messages