Browse Source

Added LRR example. Updated gitignore.

pyserial_fix
Scott Petersen 10 years ago
parent
commit
e867a4f3b4
2 changed files with 31 additions and 0 deletions
  1. +2
    -0
      .gitignore
  2. +29
    -0
      examples/lrr_example.py

+ 2
- 0
.gitignore View File

@@ -1,3 +1,5 @@
alarmdecoder.sublime-project
alarmdecoder.sublime-workspace
build/
dist
tmp


+ 29
- 0
examples/lrr_example.py View File

@@ -0,0 +1,29 @@
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())

# Set up an event handler and open the device
device.on_lrr_message += handle_lrr_message
with device.open():
while True:
time.sleep(1)

except Exception, ex:
print 'Exception:', ex

def handle_lrr_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
print sender, message.partition, message.event_type, message.event_data

if __name__ == '__main__':
main()

Loading…
Cancel
Save