Can Python serial support run at 45.45 baud?
Grant Edwards
grante at visi.com
Sun Feb 15 00:03:03 EST 2009
On 2009-02-14, John Nagle <nagle at animats.com> wrote:
> John Nagle wrote:
>
>> OK, tried to open the port, using Python 2.6, latest PySerial
>> and PyWin32:
>>
>> ser = serial.Serial(port, baudrate=baud,
>> bytesize=serial.FIVEBITS,
>> parity=serial.PARITY_NONE,
>> stopbits=serial.STOPBITS_TWO)
>>
>> 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.
>
> OK, here's what's wrong. The allowed numbers for stop bits in Windows are
>
> ONESTOPBIT 0 1 stop bit.
> ONE5STOPBITS 1 1.5 stop bits.
> TWOSTOPBITS 2 2 stop bits.
>
> The Python interface, however, only exports STOPBITS_ONE and STOPBITS_TWO.
> See "serialutil.py", at line 9, and "serialwin32.py" at lines 141-146.
That should be simple enough to fix.
> Linux has a different set of restrictions; Linux offers only 1 or 2 stop
> bits, and won't do arbitrary baud rates via the "termios" data structure,
> although there are other ways to request that.
It can be done via the ioctl that setserial uses, but that's
specific to a very few low-level drivers like the 16x50 one --
which is probably the one that matters to the OP, though he
hasn't said so.
--
Grant
More information about the Python-list
mailing list