From ee9803e6e2d9b2fa4ba8a7fa93f89f38dc31c98e Mon Sep 17 00:00:00 2001 From: Scott Petersen Date: Sun, 9 Jun 2013 17:31:52 -0700 Subject: [PATCH] Added support for clearing and faulting zones. --- pyad2usb/ad2usb.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pyad2usb/ad2usb.py b/pyad2usb/ad2usb.py index 4ae7225..760c00d 100644 --- a/pyad2usb/ad2usb.py +++ b/pyad2usb/ad2usb.py @@ -190,6 +190,10 @@ class AD2USB(object): self.emulate_lrr = False self.deduplicate = False + @property + def id(self): + return self._device.id + def open(self, baudrate=None, interface=None, index=None, no_reader_thread=False): """ Opens the device. @@ -245,9 +249,19 @@ class AD2USB(object): """ self._device.write('=') - @property - def id(self): - return self._device.id + def fault_zone(self, zone, simulate_wire_problem=False): + """ + Faults a zone if we are emulating a zone expander. + """ + status = 2 if simulate_wire_problem else 1 + + self._device.write("L{0:02}{1}".format(zone, status)) + + def clear_zone(self, zone): + """ + Clears a zone if we are emulating a zone expander. + """ + self._device.write("L{0:02}0".format(zone)) def _wire_events(self): """