Greetings, I am using Linux (Gentoo, 2.6.9) to send data over a serial
port (RS232) to a RS232->RS485 adapter. The way the RS485 is setup it
uses the RTS line as a bus-enable, so when that line is asserted by my
board, it puts itself on the bus so then any data I send actually goes
on the bus. Once the data is done, it needs to un-couple from the bus
(de-assert the RTS line) quickly. The actual data is in the Modbus RTU
protocol, which has rather tight timing specs.
I have set the CRTSCTS flag in c_clags for ttyS0, but that appears to
do nothing at all, certainly never raises the CTS line.
I can probably control this line manually with ioctrl() but I have my
doubts this would work for timing specs, after the last character is
sent, we need to be off the bus in 2ms or less. I don't think a
user-level function call is guaranteed (while Linux is doing other
stuff too) to be done in that amount of time.
After many searches all over Yahoo and Google I found many writeups
about this but all are from 1994-1999, and the fixes were either a
cludey driver fix (and the files referenced don't appear to even be
named the same, etc), or it was recommended to simply use a hardware
solution instead of software.
I'm surprised this bridge has not been crossed before. Basically what
I'm looking for is info on how to setup a serial port on a small
single-board computer (shouldn't matter though, Linux runs on it fine,
etc). So it will assert the RTS line (and the CTS if needed, none of
the other devices on this bus talk without being talked to first), send
data, then unassert the RTS line, and listen for the response, catch is
we need to unassert the RTS line fairly quickly after we are done
sending data. Ideally this would be done at the driver level, so we
would just send the data with a normal write() function or such and the
asserting of the line would be done in something more clean (and
faster) than just user-space executing code.
This wouldn't appear to be rocket science (although ironcally it is
going into an airplane), yet I have yet to find any good semi-recent
info about this.
Any help would be GREATLY appreciated!!
Thank you,
Mark Brodis
|