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 Kevin O'Connor
parent 41ce7cdf1c
commit 7373e92092
1 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@ class SerialReader:
try:
if self.baud:
self.ser = serial.Serial(
self.serialport, self.baud, timeout=0)
self.serialport, self.baud, timeout=0, exclusive=True)
else:
self.ser = open(self.serialport, 'rb+')
except (OSError, IOError, serial.SerialException) as e:
@ -284,7 +284,7 @@ def stk500v2_leave(ser, reactor):
# Attempt an arduino style reset on a serial port
def arduino_reset(serialport, reactor):
# 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)
reactor.pause(reactor.monotonic() + 0.100)
# Then toggle DTR