Open
Description
Hello! I am successfully using this library to implement a sensor device with 24 holding registers which can be read. This all works beautifully at higher baud rates. However, at 9600 baud it times out quite often (about 1/4 of requests).
To be clear, this sometimes times out when reading 24 registers in a single request. However it functions fine at higher baud rates such as 115200.
Device: Adafruit RP2040 Feather
Baud: 9600
MVP device code to replicate issue:
#include <Arduino.h>
#include <ArduinoRS485.h> // ArduinoModbus depends on the ArduinoRS485 library
#include <ArduinoModbus.h>
void setup()
{
Serial.begin(115200);
//slave id 1
if ( !ModbusRTUServer.begin(1,9600) )
{
Serial.println("Failed to start Modbus RTU Server!");
while (1);
}
// configure 24 registers, starting at address 1
ModbusRTUServer.configureHoldingRegisters(1,24);
}
void loop()
{
// poll for Modbus RTU requests
if (ModbusRTUServer.poll() )
{
Serial.println("Received request!");
}
}
RS485.h timing mod for things to work on RP2040:
#define RS485_DEFAULT_PRE_DELAY 100
#define RS485_DEFAULT_POST_DELAY 5000
BTW: I can replicate the issue when reading fewer registers at once, but it is much easier to replicate when performing larger requests (reading multiple registers).
Looking forward to your thoughts!
Thank you,
Michael