public inbox for gentoo-embedded@lists.gentoo.org
 help / color / mirror / Atom feed
From: David Relson <relson@osagesoftware.com>
To: gentoo-embedded@lists.gentoo.org
Cc: bob.dunlop@xyzzy.org.uk
Subject: Re: [gentoo-embedded] serial port handling question
Date: Thu, 14 Jan 2010 07:29:13 -0500	[thread overview]
Message-ID: <20100114072913.2d8c52de@osage.osagesoftware.com> (raw)
In-Reply-To: <20100114100531.GA16436@xyzzy.org.uk>

On Thu, 14 Jan 2010 10:05:31 +0000
Bob Dunlop wrote:

> 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

Sweet!  Very sweet!

This sounds exactly like what I want.  I saw the TIOCM_xxx symbols
being used in serial8250_get_mctrl() and serial8250_set_mctrl(), but
didn't know how to access those functions.

I'll test it later this morning when I get to work.

Regards,

David



  reply	other threads:[~2010-01-14 12:29 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
2010-01-14 12:29   ` David Relson [this message]
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=20100114072913.2d8c52de@osage.osagesoftware.com \
    --to=relson@osagesoftware.com \
    --cc=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