1.1.23 fix #41 pyserial also drives usb control signals wrong on windows

This commit is contained in:
Kevin Hester
2020-12-14 07:44:30 +08:00
parent 6bd1fc5e1e
commit 86005c0dda
5 changed files with 54 additions and 18 deletions

View File

@@ -614,8 +614,6 @@ class StreamInterface(MeshInterface):
"""Write an array of bytes to our stream and flush"""
self.stream.write(b)
self.stream.flush()
while self.stream.out_waiting != 0:
time.sleep(0.1) # It seems that on windows flush might return before all bytes actually sent?
def _readBytes(self, len):
"""Read an array of bytes from our stream"""
@@ -722,11 +720,11 @@ class SerialInterface(StreamInterface):
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
self.stream.port = devPath
# OS-X seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
# OS-X/Windows seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
# control and will always drive RTS either high or low (rather than letting the CP102 leave
# it as an open-collector floating pin). Since it is going to drive it anyways we want to make
# sure it is driven low, so that the TBEAM won't reset
if platform.system() == 'Darwin':
if platform.system() != 'Linux':
self.stream.rts = False
self.stream.open()
@@ -736,7 +734,7 @@ class SerialInterface(StreamInterface):
def _disconnected(self):
"""We override the superclass implementation to close our port"""
if platform.system() == 'Darwin':
if platform.system() != 'Linux':
self.stream.rts = True # Return RTS high, so that the reset button still works
StreamInterface._disconnected(self)