0

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)?

Micke
  • 2,251
  • 5
  • 33
  • 48
OrangeTux
  • 11,142
  • 7
  • 48
  • 73
  • Usually the Linux serial port driver has to be configured into RS-485 mode using the **TIOCSRS485** ioctl. This ioctl takes a data structure that specifies how the RTS handshake signal is repurposed and should control the transmitter. There's a parameter to specify the hold-up time that you're asing for. Read http://lxr.free-electrons.com/source/Documentation/serial/serial-rs485.txt You probably should do a get ioctl to read the structure, increase that hold-up time, and do a set ioctl. – sawdust Jun 10 '14 at 00:59

2 Answers2

0

You can set RTS manually with:

setRTS(level=True)

and then clear it after a 25ms delay with:

setRTS(level=False)
jramirez
  • 8,537
  • 7
  • 33
  • 46
0

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.

OrangeTux
  • 11,142
  • 7
  • 48
  • 73