Skip to content

Commit

Permalink
Fix initialization with CH340 UARTs
Browse files Browse the repository at this point in the history
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 #5.
  • Loading branch information
grigorig committed Dec 15, 2015
1 parent 293ce2c commit d391187
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stcgal/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,10 @@ def connect(self):
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
Expand Down

0 comments on commit d391187

Please sign in to comment.