Gentoo Archives: gentoo-embedded

From: Peter Stuge <peter@×××××.se>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] serial port handling question
Date: Thu, 14 Jan 2010 05:08:48
Message-Id: 20100114050825.26009.qmail@stuge.se
In Reply to: Re: [gentoo-embedded] serial port handling question by David Relson
1 David Relson wrote:
2 > > > The sensor is controlled (in part) by setting RTS on and off.
3 > >
4 > > What is controlled, exactly? What is RTS being used for? If it is
5 > > indeed flow control then you are lucky and can simply enable
6 > > hardware flow control for the serial port, and Linux will then
7 > > take care of everything for you.
8 >
9 > Not sure (insufficient documentation). The functions setting and
10 > clearing RTS have names like RS485_RTS_Receiver_Enable and
11 > RS485_RTS_Transmitter_Enable.
12
13 That definately suggests that RTS/CTS would be used for flow control.
14
15
16 > My query as to the meaning/purpose of the routines is awaiting an
17 > answer..
18
19 Hopefully they will confirm that it's for flow control.
20
21 Then you can simply ignore everything related to RTS, as Linux will
22 take care of it for you. Just read from the opened tty device and
23 you'll get data when there is some. Linux also buffers writes, so if
24 a write() call succeeds then data will eventually go out on the port.
25
26
27 > The RS485 routines mentionned above only change RTS. DTR remains on.
28 > Attempts to change both (using CRTSCTS and tcsetattr()) didn't work.
29
30 With tcsetattr() you'd use B0 in the CBAUD field to unset both
31 signals, and any B value other than B0 to set them. You can use
32 cfsetispeed() and cfsetospeed() to conveniently change only the
33 baudrate in a struct termios, but since it will also affect DTR I
34 don't think that this will work.
35
36
37 > I'm well aware of the hackish nature of my "solution".
38
39 What happens if you remove the code that touches the registers and
40 simply let Linux handle flow control? I suspect you could remove some
41 of the code surrounding the outb() calls as well, since the Linux
42 serial layer implements very thorough flow control.
43
44
45 > It'll be interesting to see what unwanted side effects show up to
46 > bite me.
47
48 Unfortunately the problems may not show up until far into the future,
49 with lots of installations possibly out in the field..
50
51
52 //Peter

Replies

Subject Author
RE: [gentoo-embedded] serial port handling question Peter Bell <pbell@×××××××××.com>