Open MarioGG7 opened 1 month ago
Is not exactly clear at which point you want to get exception.
As of Modbus specification EX_ILLEGAL_ADDRESS
is returned to master on non-existent address. If you want to override this behaviour you can use onRaw()
callback but much easier is to modify the library code for this specific case.
If you want to block addReg()
from adding registers on some condition you have to inherit own class from ModbusRTU and override addReg()
implementation.
mb.slave(SLAVE_ID); mb.addHreg(REGN); mb.Hreg(REGN, 100); ....................... if(REGN > 150){"send exeption -3 illegal value"}; // how to do this? .............. }
void loop() { mb.task(); yield(); }