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
> unsigned int flags;
> /* Raise RTS and DTR.
> * Linux will have already done this but some Unix system don't
> * 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.