serialhdl: Enforce exclusive access on POSIX, this is default behavior on windows. (#1216)

Signed-off-by: Daniel Joyce <daniel.a.joyce@gmail.com>
This commit is contained in:
Daniel 2019-02-10 08:51:29 -08:00 committed by KevinOConnor
parent cd6a181429
commit fdbbda9484
1 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ class SerialReader:
try: try:
if self.baud: if self.baud:
self.ser = serial.Serial( self.ser = serial.Serial(
self.serialport, self.baud, timeout=0) self.serialport, self.baud, timeout=0, exclusive=True)
else: else:
self.ser = open(self.serialport, 'rb+') self.ser = open(self.serialport, 'rb+')
except (OSError, IOError, serial.SerialException) as e: except (OSError, IOError, serial.SerialException) as e:
@ -285,7 +285,7 @@ def stk500v2_leave(ser, reactor):
# Attempt an arduino style reset on a serial port # Attempt an arduino style reset on a serial port
def arduino_reset(serialport, reactor): def arduino_reset(serialport, reactor):
# First try opening the port at a different baud # First try opening the port at a different baud
ser = serial.Serial(serialport, 2400, timeout=0) ser = serial.Serial(serialport, 2400, timeout=0, exclusive=True)
ser.read(1) ser.read(1)
reactor.pause(reactor.monotonic() + 0.100) reactor.pause(reactor.monotonic() + 0.100)
# Then toggle DTR # Then toggle DTR