Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino hangs on any read attempt #10

Open
saspol opened this issue Jul 6, 2019 · 1 comment
Open

Arduino hangs on any read attempt #10

saspol opened this issue Jul 6, 2019 · 1 comment

Comments

@saspol
Copy link

saspol commented Jul 6, 2019

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?

@SRGDamia1
Copy link
Contributor

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());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants