|
@@ -1,69 +1,79 @@ |
|
|
|
|
|
.. _AlarmDecoder: http://www.alarmdecoder.com |
|
|
|
|
|
.. _ser2sock: http://github.com/nutechsoftware/ser2sock |
|
|
|
|
|
.. _pyftdi: https://github.com/eblot/pyftdi |
|
|
|
|
|
.. _pyusb: http://sourceforge.net/apps/trac/pyusb |
|
|
|
|
|
.. _pyserial: http://pyserial.sourceforge.net |
|
|
|
|
|
.. _pyopenssl: https://launchpad.net/pyopenssl |
|
|
|
|
|
.. _readthedocs: http://alarmdecoder.readthedocs.org |
|
|
|
|
|
.. _examples: http://github.com/nutechsoftware/alarmdecoder/tree/master/examples |
|
|
|
|
|
|
|
|
|
|
|
============ |
|
|
AlarmDecoder |
|
|
AlarmDecoder |
|
|
============= |
|
|
|
|
|
#### Interface for the [AlarmDecoder](http://www.alarmdecoder.com) (AD2) device family #### |
|
|
|
|
|
|
|
|
============ |
|
|
|
|
|
#### Interface for the `AlarmDecoder`_ (AD2) device family #### |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This Python library aims to provide a consistent interface for the [Alarm |
|
|
|
|
|
Decoder](http://www.alarmdecoder.com) product line. (AD2USB, AD2SERIAL and AD2PI) |
|
|
|
|
|
This also includes devices that have been exposed via [ser2sock](http://github.com/nutechsoftware/ser2sock), which |
|
|
|
|
|
|
|
|
This Python library aims to provide a consistent interface for the `AlarmDecoder`_ product line. (AD2USB, AD2SERIAL and AD2PI) |
|
|
|
|
|
This also includes devices that have been exposed via `ser2sock`_, which |
|
|
supports encryption via SSL/TLS. |
|
|
supports encryption via SSL/TLS. |
|
|
|
|
|
|
|
|
|
|
|
------------ |
|
|
Installation |
|
|
Installation |
|
|
------------ |
|
|
------------ |
|
|
AlarmDecoder can be installed through pip: |
|
|
AlarmDecoder can be installed through pip: |
|
|
```pip install alarmdecoder``` |
|
|
|
|
|
|
|
|
pip install alarmdecoder |
|
|
|
|
|
|
|
|
or from source: |
|
|
or from source: |
|
|
```python setup.py install``` |
|
|
|
|
|
|
|
|
python setup.py install |
|
|
|
|
|
|
|
|
* Note: python-setuptools is required for installation. |
|
|
* Note: python-setuptools is required for installation. |
|
|
|
|
|
|
|
|
|
|
|
------------ |
|
|
Requirements |
|
|
Requirements |
|
|
------------ |
|
|
------------ |
|
|
* An [AlarmDecoder](http://www.alarmdecoder.com) device |
|
|
|
|
|
|
|
|
* An `AlarmDecoder`_ device |
|
|
* Python 2.7 |
|
|
* Python 2.7 |
|
|
* [pyftdi](https://github.com/eblot/pyftdi) >= 0.9.0 |
|
|
|
|
|
* [pyusb](http://sourceforge.net/apps/trac/pyusb/) >= 1.0.0b1 |
|
|
|
|
|
* [pyserial](http://pyserial.sourceforge.net/) >= 2.7 |
|
|
|
|
|
* [pyopenssl](https://launchpad.net/pyopenssl) |
|
|
|
|
|
|
|
|
* `pyftdi`_ >= 0.9.0 |
|
|
|
|
|
* `pyusb`_ >= 1.0.0b1 |
|
|
|
|
|
* `pyserial`_ >= 2.7 |
|
|
|
|
|
* `pyopenssl`_ |
|
|
|
|
|
|
|
|
|
|
|
------------- |
|
|
Documentation |
|
|
Documentation |
|
|
------------- |
|
|
------------- |
|
|
API documentation can be found [here](http://alarmdecoder.readthedocs.org). |
|
|
|
|
|
|
|
|
API documentation can be found at `readthedocs`_. |
|
|
|
|
|
|
|
|
|
|
|
-------- |
|
|
Examples |
|
|
Examples |
|
|
-------- |
|
|
-------- |
|
|
A basic example is included below. Please see the [examples](http://github.com/nutechsoftware/alarmdecoder/tree/master/examples) directory for more. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A basic example is included below. Please see the `examples`_ directory for more.:: |
|
|
|
|
|
|
|
|
```python |
|
|
|
|
|
import time |
|
|
|
|
|
from alarmdecoder import AlarmDecoder |
|
|
|
|
|
from alarmdecoder.devices import USBDevice |
|
|
|
|
|
|
|
|
import time |
|
|
|
|
|
from alarmdecoder import AlarmDecoder |
|
|
|
|
|
from alarmdecoder.devices import USBDevice |
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
|
""" |
|
|
|
|
|
Example application that prints messages from the panel to the terminal. |
|
|
|
|
|
""" |
|
|
|
|
|
try: |
|
|
|
|
|
# Retrieve the first USB device |
|
|
|
|
|
device = AlarmDecoder(USBDevice.find()) |
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
|
""" |
|
|
|
|
|
Example application that prints messages from the panel to the terminal. |
|
|
|
|
|
""" |
|
|
|
|
|
try: |
|
|
|
|
|
# Retrieve the first USB device |
|
|
|
|
|
device = AlarmDecoder(USBDevice.find()) |
|
|
|
|
|
|
|
|
# Set up an event handler and open the device |
|
|
|
|
|
device.on_message += handle_message |
|
|
|
|
|
with device.open(): |
|
|
|
|
|
while True: |
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
# Set up an event handler and open the device |
|
|
|
|
|
device.on_message += handle_message |
|
|
|
|
|
with device.open(): |
|
|
|
|
|
while True: |
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
except Exception, ex: |
|
|
|
|
|
print 'Exception:', ex |
|
|
|
|
|
|
|
|
except Exception, ex: |
|
|
|
|
|
print 'Exception:', ex |
|
|
|
|
|
|
|
|
def handle_message(sender, message): |
|
|
|
|
|
""" |
|
|
|
|
|
Handles message events from the AlarmDecoder. |
|
|
|
|
|
""" |
|
|
|
|
|
print sender, message.raw |
|
|
|
|
|
|
|
|
def handle_message(sender, message): |
|
|
|
|
|
""" |
|
|
|
|
|
Handles message events from the AlarmDecoder. |
|
|
|
|
|
""" |
|
|
|
|
|
print sender, message.raw |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
|
main() |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
|
main() |