SensorModbusMaster icon indicating copy to clipboard operation
SensorModbusMaster copied to clipboard

Arduino hangs on any read attempt

Open saspol opened this issue 5 years ago • 1 comments

Hi, i trying to use this library on Mega:

HardwareSerial modbusSerial = Serial2; modbusMaster modbus; modbusSerial.begin(2400); modbus.begin(101, modbusSerial); float val = modbus.uint16FromRegister(0x04, 1, bigEndian);

TTL to RS485 adapter blink 8 times TX on boot, then Mega hangs on any type read register attempt. Any suggestion how to debug this?

saspol avatar Jul 06 '19 18:07 saspol

Definitely use the setDebugStream function.

If you have a second mega or any other board I would also try spying on the serial communication. That is, run your first mega with your desired program connected to your RS485 adapter and your modbus device. On your second mega connect the Rx of Serial1 to the Tx of the RS485 adapter, the Rx of Serial2 to the Rx of the adapter. Then run a very simple program that mirrors both back to the terminal: while (Serial1.available()) Serial.print(Serial1.read()); while (Serial2.available()) Serial.print(Serial2.read());

SRGDamia1 avatar Jul 08 '19 13:07 SRGDamia1