Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-embedded
Navigation:
Lists: gentoo-embedded: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-embedded@g.o
From: David Relson <relson@...>
Subject: Re: serial port handling question
Date: Thu, 14 Jan 2010 07:29:13 -0500
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


Replies:
Re: serial port handling question
-- Peter Stuge
References:
serial port handling question
-- David Relson
Re: serial port handling question
-- Bob Dunlop
Navigation:
Lists: gentoo-embedded: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: serial port handling question
Next by thread:
Re: serial port handling question
Previous by date:
RE: serial port handling question
Next by date:
Re: serial port handling question


Updated Jun 25, 2012

Summary: Archive of the gentoo-embedded mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.