summaryrefslogtreecommitdiff
path: root/serial
diff options
context:
space:
mode:
authorChris Liechti <cliechti@gmx.net>2016-05-20 00:11:02 +0200
committerChris Liechti <cliechti@gmx.net>2016-05-20 00:11:02 +0200
commitda73e89c25934bbbb81b3473dc13ad56a0c4c4b3 (patch)
tree6d99412acf2dba8b84a7fd4c9c742f1832ef80b5 /serial
parent03a65c26f90d9d50e5ea678b22c43a1b846c7378 (diff)
downloadpyserial-git-da73e89c25934bbbb81b3473dc13ad56a0c4c4b3.tar.gz
spy: add support for cancel_read and cancel_write
Diffstat (limited to 'serial')
-rw-r--r--serial/urlhandler/protocol_spy.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/serial/urlhandler/protocol_spy.py b/serial/urlhandler/protocol_spy.py
index 4921990..939d5aa 100644
--- a/serial/urlhandler/protocol_spy.py
+++ b/serial/urlhandler/protocol_spy.py
@@ -150,7 +150,10 @@ class FormatHexdump(object):
class Serial(serial.Serial):
- """Just inherit the native Serial port implementation and patch the port property."""
+ """\
+ Inherit the native Serial port implementation and wrap all the methods and
+ attributes.
+ """
# pylint: disable=no-member
def __init__(self, *args, **kwargs):
@@ -204,6 +207,16 @@ class Serial(serial.Serial):
self.formatter.rx(rx)
return rx
+ if hasattr(serial.Serial, 'cancel_read'):
+ def cancel_read(self):
+ self.formatter.control('Q-RX', 'cancel_read')
+ super(Serial, self).cancel_read()
+
+ if hasattr(serial.Serial, 'cancel_write'):
+ def cancel_write(self):
+ self.formatter.control('Q-TX', 'cancel_write')
+ super(Serial, self).cancel_write()
+
@property
def in_waiting(self):
n = super(Serial, self).in_waiting