diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-09-30 01:54:45 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-09-30 01:54:45 +0000 |
commit | 42cb91e0de152841a6d965f0e3d0e26474996c9e (patch) | |
tree | 2554e58762a1bf7572d04abbc103ba86258acaa0 /examples | |
parent | f54f5f5823fce14e88998a6ce1ce80cbc2486e88 (diff) | |
download | pyserial-42cb91e0de152841a6d965f0e3d0e26474996c9e.tar.gz |
workaround when using miniterm on older installations of the library
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@347 f19166aa-fa4f-0410-85c2-fa1106f25c8a
Diffstat (limited to 'examples')
-rw-r--r-- | examples/miniterm.py | 7 |
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 |