From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 25 21:16:57 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48F0816A420 for ; Thu, 25 Oct 2007 21:16:57 +0000 (UTC) (envelope-from ticso@cicely12.cicely.de) Received: from raven.bwct.de (raven.bwct.de [85.159.14.73]) by mx1.freebsd.org (Postfix) with ESMTP id BEE4613C4B6 for ; Thu, 25 Oct 2007 21:16:56 +0000 (UTC) (envelope-from ticso@cicely12.cicely.de) Received: from cicely5.cicely.de ([10.1.1.7]) by raven.bwct.de (8.13.4/8.13.4) with ESMTP id l9PLGtge028345; Thu, 25 Oct 2007 23:16:55 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (cicely12.cicely.de [10.1.1.14]) by cicely5.cicely.de (8.13.4/8.13.4) with ESMTP id l9PLGoH2075481 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2007 23:16:50 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (localhost [127.0.0.1]) by cicely12.cicely.de (8.13.4/8.13.3) with ESMTP id l9PLGnt5068450; Thu, 25 Oct 2007 23:16:49 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: (from ticso@localhost) by cicely12.cicely.de (8.13.4/8.13.3/Submit) id l9PLGn51068449; Thu, 25 Oct 2007 23:16:49 +0200 (CEST) (envelope-from ticso) Date: Thu, 25 Oct 2007 23:16:49 +0200 From: Bernd Walter To: Brooks Talley Message-ID: <20071025211649.GB46533@cicely12.cicely.de> References: <20071025010133.GV46533@cicely12.cicely.de> <31953061.121491193327568521.JavaMail.root@zmail.illuminati.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31953061.121491193327568521.JavaMail.root@zmail.illuminati.org> X-Operating-System: FreeBSD cicely12.cicely.de 5.4-STABLE alpha User-Agent: Mutt/1.5.9i X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED=-1.8, BAYES_00=-2.599 autolearn=ham version=3.1.7 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on cicely12.cicely.de Cc: freebsd-hackers@freebsd.org Subject: Re: Getting nonstandard serial baud rates w/FTDI X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ticso@cicely.de List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2007 21:16:57 -0000 On Thu, Oct 25, 2007 at 08:52:48AM -0700, Brooks Talley wrote: > Thanks to everyone who applied. The OpenBSD approach to setting UFTDI baud rates is definitely superior. > > However, the root of my problem turned out to be Python. Even with the new baud rate hardcoded in the UFTDI kernel module and manually added to termios.h, Python was refusing to admit that it was a valid baud rate. > > The issue is that Python (2.5.1) compiles its own termios interface module, which builds a list of allowed baud rates from the defines in termios.h. Python's termios.c does something like this: > > include > termios_constants[] = { > {"B300",B300}, > {"B1200",B1200}, > {"B2400",B2400}, > . > . > . > #ifdef B115200 > {"B115200",B115200} > #endif > #ifdef B230400 > {"B230400",B230400} > #endif > > So of course my new buad rate never got added to the list. It's a fairly ugly problem, because the valud baud rates are set in #defines in termios.h and Python wants an array of them, and of course there's no way (that I know of) to enumerate defines and get a list of those that start with "B" followed by numbers (and, of course, for all I know there's some other BXXXXX define somewhere that is not intended to indicate an allowed baud rate). > > The real solution would be to use the OpenBSD UFTDI baud rate generator and update Python's termios.c to avoid the list of valid baud rates and have it just ask the serial port to set the requested rate and report back any error. But that requires far more than my meager skills. I just added another hardcoded #ifdef to Python's termios.c and it is all working now. I will take care about the ftdi driver within the next days, but will not MFC it until the releases are done. The python part is left for someone else. -- B.Walter http://www.bwct.de http://www.fizon.de bernd@bwct.de info@bwct.de support@fizon.de