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