summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-09-30 01:54:45 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-09-30 01:54:45 +0000
commit3fc527df253e8b18b7b5f80620fc41c55f3e2c07 (patch)
tree127b3a598fcf3f88a8ccd82cc0385031a636506d
parente67c1f42dcd0e74e8044bc6823e7c7fd276f3e3a (diff)
downloadpyserial-git-3fc527df253e8b18b7b5f80620fc41c55f3e2c07.tar.gz
workaround when using miniterm on older installations of the library
-rw-r--r--pyserial/examples/miniterm.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pyserial/examples/miniterm.py b/pyserial/examples/miniterm.py
index 7290783..aaef8e4 100644
--- a/pyserial/examples/miniterm.py
+++ b/pyserial/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