You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
to
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.
The text was updated successfully, but these errors were encountered: