Can Python serial support run at 45.45 baud?
nagle at animats.com
Sat Feb 14 19:26:22 CET 2009
Grant Edwards wrote:
> On 2009-02-14, John Nagle <nagle at animats.com> wrote:
>> Can Python's serial port support be made to run at 45.45 baud,
>> the old "60 speed" Teletype machine speed?
> If your hardware and OS supports it, Python can be made to
> support it.
OK, tried to open the port, using Python 2.6, latest PySerial
ser = serial.Serial(port, baudrate=baud,
Traceback (most recent call last):
File "serialtest.py", line 27, in <module>
File "serialtest.py", line 24, in main
ser = openportbaudot(0,45.45)
File "serialtest.py", line 17, in openportbaudot
File "D:\python26\lib\site-packages\serial\serialutil.py", line 171, in __init__
File "D:\python26\lib\site-packages\serial\serialwin32.py", line 63, in open
File "D:\python26\lib\site-packages\serial\serialwin32.py", line 171, in
raise ValueError("Cannot configure port, some setting was wrong. Original
message: %s" % e)
ValueError: Cannot configure port, some setting was wrong. Original message:
(87, 'SetCommState', 'The parameter is incorrect.')
Something doesn't like "serial.FIVEBITS". That's a valid value, according
to "http://pyserial.wiki.sourceforge.net/pySerial". If changed to
"serial.EIGHTBITS", the code will execute, but of course does the wrong
thing. That looks like a bug.
I tried various values for "baud". PySerial will accept "45", and even
"45.45", although I doubt that it's really calculating the serial port divisor
values from a floating point value. (Standard serial port hardware can do
45.45 baud, and most PCs with non-USB serial ports will do it quite well.)
For my application, 45 baud should work, with two stop bits; the
tolerances aren't that tight.
More information about the Python-list