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:
parent
41ce7cdf1c
commit
7373e92092
|
@ -58,7 +58,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:
|
||||||
|
@ -284,7 +284,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
|
||||||
|
|
Loading…
Reference in New Issue