From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-embedded+bounces-3325-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1NVOpk-000430-OL
	for garchives@archives.gentoo.org; Thu, 14 Jan 2010 12:29:52 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 4CB5AE0A7D;
	Thu, 14 Jan 2010 12:29:14 +0000 (UTC)
Received: from mail.osagesoftware.com (osagesoftware.com [216.144.204.42])
	by pigeon.gentoo.org (Postfix) with ESMTP id 22F0CE0A7D
	for <gentoo-embedded@lists.gentoo.org>; Thu, 14 Jan 2010 12:29:14 +0000 (UTC)
Received: from osage.osagesoftware.com (osage.osagesoftware.com [192.168.1.10])
	by mail.osagesoftware.com (Postfix) with ESMTP id 961517BCE5;
	Thu, 14 Jan 2010 07:29:13 -0500 (EST)
Date: Thu, 14 Jan 2010 07:29:13 -0500
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
Message-ID: <20100114072913.2d8c52de@osage.osagesoftware.com>
In-Reply-To: <20100114100531.GA16436@xyzzy.org.uk>
References: <20100113185240.4bc9d721@osage.osagesoftware.com>
	<20100114100531.GA16436@xyzzy.org.uk>
Organization: Osage Software Systems, Inc.
X-Mailer: Claws Mail 3.7.3 (GTK+ 2.16.6; x86_64-pc-linux-gnu)
Precedence: bulk
List-Post: <mailto:gentoo-embedded@lists.gentoo.org>
List-Help: <mailto:gentoo-embedded+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-embedded+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-embedded+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-embedded.gentoo.org>
X-BeenThere: gentoo-embedded@lists.gentoo.org
Reply-to: gentoo-embedded@lists.gentoo.org
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Archives-Salt: 44b630a4-f727-4721-8076-3c4ffab4cc0d
X-Archives-Hash: 61e3dba1ae3b029b265f13066746886d

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