RS485 with raspberry problems??? Help me pls

337 views
Skip to first unread message

Nguyen Tu

unread,
Oct 19, 2014, 3:24:54 AM10/19/14
to libm...@googlegroups.com
Hello every one.
I use libmodbus on my raspberry pi with modbus RS485 to create a server. I connected RPi pins with module RS485 (using IC MAX3485) like this:
TX(RPi) <-------->RX(485)
RX(RPi) <-------->TX(485)
GPIO1 <--------> EN485
I set en485 pin to high lvl for transmiting data to a slave on my PC, it work good, but the problem is i cant set en485 pin to low lvl for receiving confirmation from slave! The function
I tried edit src modbus-rtu.c:
if (mode == MODBUS_RTU_RS485) {
            rs485conf
.flags = SER_RS485_ENABLED;
            rs485conf
.flags |= SER_RS485_RTS_ON_SEND; //Set logical level for RTS pin equal 1 when sending
            rs485conf
.flags &= ~(SER_RS485_RTS_AFTER_SEND); //Set logical level for RTS pin equal 0 after sending
            rs485conf
.delay_rts_before_send = 0;
            rs485conf
.delay_rts_before_send = 0;

            rs485conf
.flags |= SER_RS485_USE_GPIO;
            rs485conf
.gpio_pin = en485; // need #define en485 18 //BCM code
           
if (ioctl(ctx->s, TIOCSRS485, &rs485conf) < 0) {
               
return -1;
           
}
but it won't work!
Is any one have idea to solve my problem or sample code, pls send me. Thank you very much.

Marek Taszek

unread,
Oct 20, 2014, 4:45:57 AM10/20/14
to libm...@googlegroups.com
You have raspberry pi and max3485, i have beaglebone black and IL3585.
I use this - https://github.com/stephane/libmodbus/wiki/Beaglebone-RS485-cape but it dosen't work to the end.
First send and receive data is ok but after is CRC Error.


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages