Added exclusive locking for POSIX serial ports.
diff --git a/serial/serialutil.py b/serial/serialutil.py
index 636a10c..37eb321 100644
--- a/serial/serialutil.py
+++ b/serial/serialutil.py
@@ -185,6 +185,7 @@
write_timeout=None,
dsrdtr=False,
inter_byte_timeout=None,
+ exclusive=None,
**kwargs):
"""\
Initialize comm port object. If a "port" is given, then the port will be
@@ -211,6 +212,7 @@
self._rts_state = True
self._dtr_state = True
self._break_state = False
+ self._exclusive = None
# assign values using get/set methods using the properties feature
self.port = port
@@ -224,6 +226,8 @@
self.rtscts = rtscts
self.dsrdtr = dsrdtr
self.inter_byte_timeout = inter_byte_timeout
+ self.exclusive = exclusive
+
# watch for backward compatible kwargs
if 'writeTimeout' in kwargs:
self.write_timeout = kwargs.pop('writeTimeout')
@@ -305,6 +309,18 @@
self._reconfigure_port()
@property
+ def exclusive(self):
+ """Get the current exclusive access setting."""
+ return self._exclusive
+
+ @exclusive.setter
+ def exclusive(self, exclusive):
+ """Change the exclusive access setting."""
+ self._exclusive = exclusive
+ if self.is_open:
+ self._reconfigure_port()
+
+ @property
def parity(self):
"""Get the current parity setting."""
return self._parity