-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
i noticed that any getXXXFromRegister call takes ~31ms, so i dug deeper and found that in getRegisters() it adds a Delay of 25ms presumably for when the message fails and then wants to retry (correct me if im wrong).
Long story short: i changed
while (respSize != (numRegisters*2 + 5) && tries < 10)
{
// Send out the command (this adds the CRC)
respSize = sendCommand(command, 8);
tries++;
delay(25);
}
to
while (respSize != (numRegisters*2 + 5) && tries < 10)
{
// Send out the command (this adds the CRC)
respSize = sendCommand(command, 8);
tries++;
if(respSize != (numRegisters*2 + 5)) {
delay(25);
}
}
So it only adds the Delay if the response size is wrong, works for me, and now i have times of ~7ms per call.
You could argue that modbus needs these delays, but as for now i dont see anything where its needed, and the sendCommand() actively waits for a response with a delay of 1ms until it gets an answer anyways, so i see this as a worthy performance improvement.
Metadata
Metadata
Assignees
Labels
No labels