summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/miniterm.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/miniterm.py b/examples/miniterm.py
index 7290783..aaef8e4 100644
--- a/examples/miniterm.py
+++ b/examples/miniterm.py
@@ -133,7 +133,12 @@ REPR_MODES = ('raw', 'some control', 'all control', 'hex')
class Miniterm:
def __init__(self, port, baudrate, parity, rtscts, xonxoff, echo=False, convert_outgoing=CONVERT_CRLF, repr_mode=0):
- self.serial = serial.serial_for_url(port, baudrate, parity=parity, rtscts=rtscts, xonxoff=xonxoff, timeout=1)
+ try:
+ self.serial = serial.serial_for_url(port, baudrate, parity=parity, rtscts=rtscts, xonxoff=xonxoff, timeout=1)
+ except AttributeError:
+ # happens when the installed pyserial is older than 2.5. use the
+ # Serial class directly then.
+ self.serial = serial.Serial(port, baudrate, parity=parity, rtscts=rtscts, xonxoff=xonxoff, timeout=1)
self.echo = echo
self.repr_mode = repr_mode
self.convert_outgoing = convert_outgoing