Open SWoto opened 3 years ago
This issue tracker is only to be used to report bugs or feature requests. This topic is more appropriate for the Arduino Forum. I'm sure we'll be able to help you with your problem over there.
Please do this:
</>
button on the toolbar).Update: the forum thread
@per1234
Probably due to the hardware (SAMD), the code tries to reply too early and it isn't able to do so. I checked with the oscilloscope and although the debugging showed that the reply was correctly built and sent, the signal wasn't there.
I've tried adding some delay to check if this was the problem and it solved. I tested from 5ms to 500ms and if worked form 110 to 500.
Before
void ModbusRTUServerClass::poll()
{
uint8_t request[MODBUS_RTU_MAX_ADU_LENGTH];
int requestLength = modbus_receive(_mb, request);
if (requestLength > 0) {
modbus_reply(_mb, request, requestLength, &_mbMapping);
}
}
After
void ModbusRTUServerClass::poll()
{
uint8_t request[MODBUS_RTU_MAX_ADU_LENGTH];
int requestLength = modbus_receive(_mb, request);
#ifdef ARDUINO_ARCH_SAMD
delay(110);
#endif
modbus_reply(_mb, request, requestLength, &_mbMapping);
}
}
Hey everyone, hope you're all safe and sound (as possible) during these dark times.
Aditional Information
Problem
I'm using the ArduinoModbus library and so far so good. However, yesterday, I tried communicating with a different hardware with the Arduino as the slave to have its input registers read. The code, Modbus RTU Server Kitchen Sink with little modifications, receives the message right (added print function to the .cpp) but doesn't reply as it should.
Due to most past of the core code being in
c
i can't useSerial.print()
to debug and looks likeprintf
andfprintf
doesn't work (at least not for me).Have anyone managed to make those two functions work? How are you debugging it?
(Slave/Server) Serial Monitor
(Master/Client) Serial Monitor