miniterm.py: use exclusive access for native serial ports by default
Fixes #326. miniterm.py now uses exclusive access for serial.Serial
instances by default. The new option --non-exclusive can be used to
override the default, disabling exclusive access for native ports. No
change for non-native ports.
diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py
index 812f146..b2d4adb 100644
--- a/serial/tools/miniterm.py
+++ b/serial/tools/miniterm.py
@@ -809,6 +809,13 @@
default=default_dtr)
group.add_argument(
+ "--non-exclusive",
+ dest="exclusive",
+ action="store_false",
+ help="disable locking for native ports",
+ default=True)
+
+ group.add_argument(
"--ask",
action="store_true",
help="ask again for port when open fails",
@@ -929,6 +936,9 @@
sys.stderr.write('--- forcing RTS {}\n'.format('active' if args.rts else 'inactive'))
serial_instance.rts = args.rts
+ if isinstance(serial_instance, serial.Serial):
+ serial_instance.exclusive = args.exclusive
+
serial_instance.open()
except serial.SerialException as e:
sys.stderr.write('could not open port {!r}: {}\n'.format(args.port, e))