From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 25 00:25:18 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 BC16016A418 for ; Thu, 25 Oct 2007 00:25:18 +0000 (UTC) (envelope-from fbsd-hackers@mawer.org) Received: from outbound.icp-qv1-irony-out3.iinet.net.au (outbound.icp-qv1-irony-out3.iinet.net.au [203.59.1.148]) by mx1.freebsd.org (Postfix) with ESMTP id 39BAA13C4BF for ; Thu, 25 Oct 2007 00:25:18 +0000 (UTC) (envelope-from fbsd-hackers@mawer.org) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKd8H0fLzq3r/2dsb2JhbAAM X-IronPort-AV: E=Sophos;i="4.21,326,1188748800"; d="scan'208";a="171703989" Received: from unknown (HELO [10.24.1.1]) ([203.206.173.235]) by outbound.icp-qv1-irony-out3.iinet.net.au with ESMTP; 25 Oct 2007 08:13:07 +0800 Message-ID: <471FDF38.7070702@mawer.org> Date: Thu, 25 Oct 2007 10:11:36 +1000 From: Antony Mawer User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: ticso@cicely.de References: <6511247.119521193244786830.JavaMail.root@zmail.illuminati.org> <20071024225910.GU46533@cicely12.cicely.de> In-Reply-To: <20071024225910.GU46533@cicely12.cicely.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, Brooks Talley Subject: Re: Getting nonstandard serial baud rates w/FTDI X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list 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 00:25:18 -0000 On 25/10/2007 8:59 AM, Bernd Walter wrote: > 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)) ... >> 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. There looks to me to be an issue with an assignment operation (=) rather than equality test (==) in the following section of the patch: + /* Special cases for 2M and 3M. */ + if ((speed >= UI(3000000 * 0.97)) && (speed = UI(2000000 * 0.97)) \ && (speed <= UI(2000000 * 1.03))) { result = 1; goto done; } I would imagine the "(speed = UI(2000000 * 0.97))" should be == rather than = for this to make sense...? --Antony