From: "Peter Bell" <pbell@ink-media.com>
To: <gentoo-embedded@lists.gentoo.org>
Subject: RE: [gentoo-embedded] serial port handling question
Date: Thu, 14 Jan 2010 18:53:50 +0800 [thread overview]
Message-ID: <02DDECDCCD6F47B78112F7F1AB3A0C91@Desktop> (raw)
In-Reply-To: <20100114050825.26009.qmail@stuge.se>
RS485 is a half-duplex bus, so this looks like a transmit enable rather than
flow control - and generally the transmit enable timing is quite critical,
since you have to leave it asserted until the last bit is sent from the UART
(so the normal "interrupt of THRE or FIFO low" is useless - you have to use
a TDRE interrupt), and then needs to be very quickly turned around before
the addressed device comes back with it's response.
If you don't want to bitbash the control registers in userland you are just
going to have to add a special mode to the driver, I'm afraid - none of the
RS485 implementations I've ever seen will work correctly using the flow
control semantics that the kernel implements.
Pete
-----Original Message-----
From: Peter Stuge [mailto:peter@stuge.se]
Sent: Thursday, January 14, 2010 1:08 PM
To: gentoo-embedded@lists.gentoo.org
Subject: Re: [gentoo-embedded] serial port handling question
David Relson wrote:
> > > The sensor is controlled (in part) by setting RTS on and off.
> >
> > What is controlled, exactly? What is RTS being used for? If it is
> > indeed flow control then you are lucky and can simply enable
> > hardware flow control for the serial port, and Linux will then
> > take care of everything for you.
>
> Not sure (insufficient documentation). The functions setting and
> clearing RTS have names like RS485_RTS_Receiver_Enable and
> RS485_RTS_Transmitter_Enable.
That definately suggests that RTS/CTS would be used for flow control.
> My query as to the meaning/purpose of the routines is awaiting an
> answer..
Hopefully they will confirm that it's for flow control.
Then you can simply ignore everything related to RTS, as Linux will
take care of it for you. Just read from the opened tty device and
you'll get data when there is some. Linux also buffers writes, so if
a write() call succeeds then data will eventually go out on the port.
> The RS485 routines mentionned above only change RTS. DTR remains on.
> Attempts to change both (using CRTSCTS and tcsetattr()) didn't work.
With tcsetattr() you'd use B0 in the CBAUD field to unset both
signals, and any B value other than B0 to set them. You can use
cfsetispeed() and cfsetospeed() to conveniently change only the
baudrate in a struct termios, but since it will also affect DTR I
don't think that this will work.
> I'm well aware of the hackish nature of my "solution".
What happens if you remove the code that touches the registers and
simply let Linux handle flow control? I suspect you could remove some
of the code surrounding the outb() calls as well, since the Linux
serial layer implements very thorough flow control.
> It'll be interesting to see what unwanted side effects show up to
> bite me.
Unfortunately the problems may not show up until far into the future,
with lots of installations possibly out in the field..
//Peter
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4770 (20100114) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
next prev parent reply other threads:[~2010-01-14 10:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 23:52 [gentoo-embedded] serial port handling question David Relson
2010-01-14 2:55 ` Peter Stuge
2010-01-14 4:30 ` David Relson
2010-01-14 5:08 ` Peter Stuge
2010-01-14 10:53 ` Peter Bell [this message]
2010-01-14 2:56 ` Daniel Stonier
2010-01-14 3:47 ` Peter Stuge
2010-01-14 4:09 ` David Relson
2010-01-14 10:05 ` Bob Dunlop
2010-01-14 12:29 ` David Relson
2010-01-14 16:17 ` Peter Stuge
2010-01-14 16:21 ` Relson, David
2010-01-14 16:29 ` Peter Stuge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=02DDECDCCD6F47B78112F7F1AB3A0C91@Desktop \
--to=pbell@ink-media.com \
--cc=gentoo-embedded@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox