Getting nonstandard serial baud rates w/FTDI
Bernd Walter
ticso at cicely12.cicely.de
Wed Oct 24 16:22:37 PDT 2007
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 at bwct.de info at bwct.de support at fizon.de
More information about the freebsd-hackers
mailing list