From af153a89e7410453670c468195b92a7c34e8a35b Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Tue, 15 Dec 2015 16:43:37 +0100 Subject: [PATCH] Fix initialization with CH340 UARTs Initialization is messed up with older Linux kernels and that results in 9600 baud being used unconditionally. Setting the baud rate separately seems to work around this successfully. --- stcgal/protocols.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stcgal/protocols.py b/stcgal/protocols.py index 770a800..77979e6 100644 --- a/stcgal/protocols.py +++ b/stcgal/protocols.py @@ -732,8 +732,11 @@ class StcBaseProtocol: Set up serial port, send sync sequence and get part info. """ - self.ser = serial.Serial(port=self.port, baudrate=self.baud_handshake, + self.ser = serial.Serial(port=self.port, parity=self.PARITY) + # set baudrate separately to workaround a bug with the CH340 driver + # in older Linux kernels + self.ser.baudrate = self.baud_handshake # fast timeout values to deal with detection errors self.ser.timeout = 0.5