-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Master on RaspberryPi (UART+GPIO) receive a <0> Byte at the beginning of each answer #302
Comments
Did you turn off serial console on RPi which is turned on by default ? If not, use |
Make sure you're using correct GPIO numbering scheme (fork follows, BCM numbering) and correct GPIO number. |
I receive <00><01><04><02><03><28> instead of <01><04><02><03><28>. |
I see, try using different baud rate if you can. I have observed this <0> problem before while using |
I believe this is the issue you're facing |
The problem exists both with 9600 and with 57600. |
Or just flush buffer after opening the port. |
Did you try flushing the port after opening it ? |
in modbus-rtu.c static int _set_GPIO_pin(modbus_t *ctx,int value) added -> and the <0> Byte at beginning is away! |
Instead of changing the source, you could have just used in your user program anywhere after |
@dhruvvyas90 Thank you for your help! |
I could be a good idea to add the modbus_flush() trick to https://github.com/stephane/libmodbus/wiki/Libmodbus-on-Raspberry-pi |
@stephane: Let me modify the wiki post. You may close this issue since it has been solved. |
I changed "server" in "master" in order to guard against misunderstandings. |
@dhruvvyas90 thank you for your answers and the wiki. Closed. |
hello happy to say hello. I can not compile the library in a raspberry pi who can help me? Greetings from Venezuela pi@homecontrol:~/libmodbus/tests $ gcc random-test-server.c -o random-test-server pkg-config -libs -cflags libmodbus |
hello, i´m trying to compile the modbus-rtu.c but there is a fatal error that says: "no such file or directory #include<config.h>" can anyone help me ? Thanks |
Hi, does this problem persist in the current version? The solution to modify modbus-rtu.c no longer applies since the code in the post no longer exists. |
1.libmodbus version
2.OS/environment/architecture
3.libmodbus backend (TCP, RTU, IPv6)
4.Modbus messages
TEST with /dev/ttyUSB0(with USB RS 485 dongle) - allways OK
pi@raspberrypi ~/SW-QT5/ModbusProjekt/ModbusProjekt/libmodbus-master/rpi-test $ sudo ./test
sec_to=0 usec_to=500000
Rpi RTU enabled.
BCM Pin set as 18.
RPI pin exported and pin direction configured successfully.
Opening /dev/ttyUSB0 at 9600 bauds (N, 8, 1)
[01][04][00][00][00][01][31][CA]
GPIO18 written : 1 successfully !
GPIO18 written : 0 successfully !
Waiting for a confirmation...
<01><04><02><03><28>
Date received is : 808
RPI BCM Pin Unexported successfully.
TEST with /dev/ttyAMA0 - allways <0> Byte... Error
pi@raspberrypi ~/libmodbus-master/rpi-test $ sudo ./test
sec_to=0 usec_to=500000
Rpi RTU enabled.
BCM Pin set as 18.
RPI pin exported and pin direction configured successfully.
Opening /dev/ttyAMA0 at 9600 bauds (N, 8, 1)
[01][04][00][00][00][01][31][CA]
GPIO18 written : 1 successfully !
GPIO18 written : 0 successfully !
Waiting for a confirmation...
ERROR Connection timed out: select
<00><01><04><02><03><25><78><1B>Bytes flushed (0)
Date received is : 0
RPI BCM Pin Unexported successfully.
pi@raspberrypi ~/libmodbus-master/rpi-test $ sudo ./test
sec_to=0 usec_to=500000
Rpi RTU enabled.
BCM Pin set as 18.
RPI pin exported and pin direction configured successfully.
Opening /dev/ttyAMA0 at 9600 bauds (N, 8, 1)
[01][04][00][00][00][01][31][CA]
GPIO18 written : 1 successfully !
GPIO18 written : 0 successfully !
Waiting for a confirmation...
ERROR Connection timed out: select
<00><01><04><02><03><28>Bytes flushed (0)
Date received is : 0
RPI BCM Pin Unexported successfully.
The text was updated successfully, but these errors were encountered: