简体   繁体   中英

Control RTS line when communication via RS-485 serial

I'm trying to communicate over the serial interface RS-485 on a Linux machine with kernel 2.6.39. I'm using this breakout board together with the pySerial module. When I write something via the interface often my data gets corrupted. On the product page of the breakout board someone mentioned:

I've noticed from the beginning, that I need to have a delay of about 25 ms after I send serial data before I can bring the RTS line low otherwise the transmission gets corrupted or is not transmitted.

I discovered that the RTS line shortly gets high when I write bytes, but gets low immediately after writing. How do I keep that line high (for a bit longer)?

You can set RTS manually with:

setRTS(level=True)

and then clear it after a 25ms delay with:

setRTS(level=False)

After a lot of trial and error I think I found the problem. My presumption is that the RS-485 driver off the kernel is setting the RTS line to high for a short moment when I use serial.write(). serial.write() writes characters to /dev/ttyS1. From this moment the Linux driver for RS-485 controlls the serial bus in order to write the characters. During this operation it sets the RST line during the actual write moment for a short period to high.

I can't controll this write operation on a higher level, I think I've to hack into the driver or connect the RTS line to a different GPIO which I can control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM