From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 24 23:22:37 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 1044216A418 for ; Wed, 24 Oct 2007 23:22:37 +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 78F7E13C480 for ; Wed, 24 Oct 2007 23:22:36 +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 l9OMxHVG082478; Thu, 25 Oct 2007 00:59:17 +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 l9OMxBmS064800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2007 00:59:12 +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 l9OMxB1I065254; Thu, 25 Oct 2007 00:59:11 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: (from ticso@localhost) by cicely12.cicely.de (8.13.4/8.13.3/Submit) id l9OMxBhV065253; Thu, 25 Oct 2007 00:59:11 +0200 (CEST) (envelope-from ticso) Date: Thu, 25 Oct 2007 00:59:11 +0200 From: Bernd Walter To: Brooks Talley Message-ID: <20071024225910.GU46533@cicely12.cicely.de> References: <6511247.119521193244786830.JavaMail.root@zmail.illuminati.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6511247.119521193244786830.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: Wed, 24 Oct 2007 23:22:37 -0000 On Wed, Oct 24, 2007 at 09:53:06AM -0700, Brooks Talley wrote: > > Hi, everyone. I'm pulling my hair out in great chunks. > > I need to get Python 2.5, using pyserial 2.2, to open a FTDI-based usb to serial port at 250000 baud. The FTDI chip definitely supports this rate. The port mounts at /dev/cuaU0. > > The problem is that /usr/local/lib/python2.5/site-packages/serial/serialposix.py fails on this line: > ispeed = ospeed = getattr(TERMIOS,'B%s' % (self._baudrate)) > > So far, I have applied these patches to uftdi.c and uftdireg.h: > http://tinyurl.com/2yye2l > > Approaching this with a machete, I have also updated /usr/src/lib/libc/gen/termios.h to add B250000, and rebuilt world and the kernel, and confirmed that the updated termios.h made it to /usr/include and /usr/include/sys. termios.h is not important - they are just constants, you should be able to use raw values in software. > Any ideas on how to get this to work? It doesn't seem like it should be this difficult! You need to add support in the uftdi driver itself. There is an enum containing ftdi_8u232am_* fields and a switch/case in the driver. The hex value divides the 48MHz clock and leaves a factor 8. So 0x0018 should be the right value for 250000bps. There is an OpenBSD patch to calculate the rates dynamically: http://archive.openbsd.nu/?ml=openbsd-tech&a=2006-06&m=2083975 Something similar (but in better style IMHO) is commited to OpenBSD, which we should merge into our source. -- B.Walter http://www.bwct.de http://www.fizon.de bernd@bwct.de info@bwct.de support@fizon.de