arduino-libraries / ArduinoModbus

244 stars 116 forks source link

Race condition: ModbusRTUServer.begin() sometimes quietly rejects config #135

Open pomplesiegel opened 6 months ago

pomplesiegel commented 6 months ago

I was experiencing a very difficult to debug issue with this library on my RP2040 wherein seemingly very similar code produced a different result. Ultimately this proved to be a race condition, in which ModbusRTUServer.begin() sometimes was not accurately loading in my provided serial format and instead used the default.

int ModbusRTUServerClass::begin(int id, unsigned long baudrate, uint16_t config)

Symptoms:

Temporary resolution to issue:

Proposed resolution:

Details: