Fix initialization with CH340 UARTs

Initialization is messed up on older Linux kernels and that results
in 9600 baud being used unconditionally in some cases. Setting the
baud rate separately seems to work around this successfully.

Fixes grigorig/stcgal#5.
This commit is contained in:
Grigori Goronzy 2015-12-15 16:43:37 +01:00 committed by Grigori Goronzy
parent 293ce2c749
commit d3911870c3

View File

@ -732,8 +732,10 @@ class StcBaseProtocol:
Set up serial port, send sync sequence and get part info.
"""
self.ser = serial.Serial(port=self.port, baudrate=self.baud_handshake,
parity=self.PARITY)
self.ser = serial.Serial(port=self.port, parity=self.PARITY)
# set baudrate separately to work around a bug with the CH340 driver
# on older Linux kernels
self.ser.baudrate = self.baud_handshake
# fast timeout values to deal with detection errors
self.ser.timeout = 0.5