Talking to a usb device (serial terminal)

blaine frikker at gmail.com
Tue Mar 4 18:31:09 EST 2008


> It looks like the fastest speed supported by python termios on
> Linux is B460800 (uses a constant of 0x1004).  If you look in
> /usr/include/..., baud rates do go up to 921600 (which uses a
> constant of 0x1007).
>
> Try using the appropriate constant from /usr/include/... (for
> the target platform, of course).
>
> --
> Grant Edwards                   grante             Yow! Please come home with
>                                   at               me ... I have Tylenol!!
>                                visi.com

I want to thank you SO MUCH for all your help.  Here are my issues
that I overcame (sanity check):
1.  Why did we have to use 0x1007, instead of 0x10007 that our grep
command returns?
2.  PySerial works beautifully.  Thank you for the suggestion.  What I
had to do was add this to the PySerial source root in serialpostix.py,
after the import termios:

termios.B921600 = 0x1007

because PySerial looks for the actual baud rate in termios (via
getattr()) which does not exist.  PySerial actually defines the
following baud rates, but termios does not handle it:
    #default values, may be overriden in subclasses that do not
support all values
    BAUDRATES =
(50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,
 
19200,38400,57600,115200,230400,460800,500000,576000,921600,
 
1000000,1152000,1500000,2000000,2500000,3000000,3500000,4000000)
... so now I can pass 921600 as a parameter to PySerial! :)

So my next question is - I would like to contribute to the python
source tree by updating termios.h to handle the higher baud rates by
default.  Is this a good opportunity for me to submit a patch? I've
never done this before but have always been interested in doing so.

Thanks again!
Blaine



More information about the Python-list mailing list