public inbox for gentoo-embedded@lists.gentoo.org
 help / color / mirror / Atom feed
From: Peter Stuge <peter@stuge.se>
To: gentoo-embedded@lists.gentoo.org
Subject: Re: [gentoo-embedded] serial port handling question
Date: Thu, 14 Jan 2010 06:08:25 +0100	[thread overview]
Message-ID: <20100114050825.26009.qmail@stuge.se> (raw)
In-Reply-To: <20100113233030.21b059e8@osage.osagesoftware.com>

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



  reply	other threads:[~2010-01-14  5:08 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 [this message]
2010-01-14 10:53       ` Peter Bell
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=20100114050825.26009.qmail@stuge.se \
    --to=peter@stuge.se \
    --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