Re: Getting nonstandard serial baud rates w/FTDI
- From: Brooks Talley <brooks@xxxxxxxxxxxxxx>
- Date: Thu, 25 Oct 2007 08:52:48 -0700 (PDT)
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.h>
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.
-Brooks
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Getting nonstandard serial baud rates w/FTDI
- From: Bernd Walter
- Re: Getting nonstandard serial baud rates w/FTDI
- References:
- Re: Getting nonstandard serial baud rates w/FTDI
- From: Bernd Walter
- Re: Getting nonstandard serial baud rates w/FTDI
- Prev by Date: Re: How to get a kthread ID?
- Next by Date: Re: Serial speed for boot device selection prompt
- Previous by thread: Re: Getting nonstandard serial baud rates w/FTDI
- Next by thread: Re: Getting nonstandard serial baud rates w/FTDI
- Index(es):