From: Bob Dunlop <bob.dunlop@xyzzy.org.uk>
To: gentoo-embedded@lists.gentoo.org
Subject: Re: [gentoo-embedded] serial port handling question
Date: Thu, 14 Jan 2010 10:05:31 +0000 [thread overview]
Message-ID: <20100114100531.GA16436@xyzzy.org.uk> (raw)
In-Reply-To: <20100113185240.4bc9d721@osage.osagesoftware.com>
On Wed, Jan 13 at 06:52, David Relson wrote:
...
> Directly tweaking the I/O port runs against the grain, but it's the
> only thing I've found that works.
>
> Is there a better way to control the chip?
I know others have commented on using automatic settings for flow control
etc, but if you need to control the lines directly there are an often
neglected set of ioctls to do this.
Some snippets of code, last used on x86 four years ago but it looks like
the hooks are still in the kernel and a fair number of device drivers.
unsigned int flags;
/* Raise RTS and DTR.
* Linux will have already done this but some Unix system don't and
* some wait for DCD before doing so, so make it explicit.
*/
flags = TIOCM_RTS | TIOCM_DTR;
if ( ioctl( fd, TIOCMBIS, &flags ) != 0 )
{
fprintf( stderr,"Failed to raise RTS and DTR. Errno %d\n", errno );
/* Possibly not fatal so we continue */
}
...
/* Drop RTS */
flags = TIOCM_RTS;
if ( ioctl( fd, TIOCMBIC, &flags ) != 0 )
{
fprintf( stderr,"Failed to clear RTS. Errno %d\n", errno );
}
As well as set and clear there is a get (TIOCMGET) useful for checking DCD.
--
Bob Dunlop
next prev parent reply other threads:[~2010-01-14 10:06 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
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 [this message]
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=20100114100531.GA16436@xyzzy.org.uk \
--to=bob.dunlop@xyzzy.org.uk \
--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