My device (sensor) is a MODBUS slave. How should my device behave in the following conditions?
1- Master sends query for 100 register write (FC 16), of which first 50 register values are in valid range and remaining 50 are invalid.
2- Master sends query for 100 register write (FC 16), of which first 50 register values are in invalid range and remaining 50 are in the valid range.
Should the slave not send exception in both cases?
Should sensor allow "write operation" to valid registers?
The master/client's command has not been fully executed. The reasonable expectation of writing all values to valid registers is not accomplished.
The slave should send an exception to either or both cases, ignore the message and change nothing in its slave registers.
The steady stream of exceptions should eventually wake up whoever needs the performance related to data exchange to investigate/correct the situation on master/client end.
I also had a similar understanding as yours @David. But I get confused when I read the following the MODBUS protocol document.
03 ILLEGAL DATA VALUE
A value contained in the query data field is not an allowable value for server (or slave). This indicates a fault in the structure of the remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.