Closed falahati closed 4 years ago
Thanks :green_heart:
@falahati Kool, I'll have hardware on hand this weekend as soon as tested I'll let you know.
@falahati @yaacov , I tested the solution but did not work, the callback got not called
I changed:
@@ -589,7 +590,7 @@ bool Modbus::readRequest()
bool Modbus::relevantAddress(uint8_t unitAddress)
{
// Every device should listen to broadcast messages.
- if (isBroadcast())
+ if (unitAddress==MODBUS_BROADCAST_ADDRESS)
{
return true;
}
and reviewing further I thought we needed:
@@ -838,7 +839,7 @@ uint8_t Modbus::executeCallback(uint8_t slaveAddress, uint8_t callbackIndex, uin
}
}
- return isBroadcast ? STATUS_ACKNOWLEDGE : STATUS_ILLEGAL_FUNCTION;
+ return isBroadcast ? STATUS_OK : STATUS_ILLEGAL_FUNCTION;
}
/**
In order for the cleanup to happen at uint8_t Modbus::poll() after the
Modbus::createResponse();in the
WriteRespose()`
// Execute the incoming request and create the response.
uint8_t status = Modbus::createResponse();
// Check if the callback execution succeeded.
if (status != STATUS_OK)
{
return Modbus::reportException(status);
}
// Write the create response to the serial interface.
return Modbus::writeResponse();
}
With the above changes I got a functional good working solution.
@dgoo2308 Thanks ! can you make a PR with the fixes ?
@yaacov not yet, still need further testing, I noticed writing to holding register with no holding register callback crashes, I just came to a solution that was functional, but it need to be reliable for me.
Missing feature from #34 and in regard to #32.
Please test before merging; I don't currently have hardware close to me to test it on.