John-Mark Gurney a37b25c6e0 | 2 years ago | |
---|---|---|
.gitignore | 7 years ago | |
Makefile | 3 years ago | |
README.md | 7 years ago | |
adtwist.py | 3 years ago | |
requirements.txt | 2 years ago | |
setup.py | 2 years ago |
This is a wrapper around the python module alarmdecoder that makes it compatible w/ the twisted framework. This replaces the included device so that you don’t have to use a thread to handle I/O from the device.
Currently it is only tested w/ a AD2USB via a serial port. There is no USB auto detect code included.
Sample code:
from adtwist import adtwist
from twisted.internet import reactor
def msgcbfun(ad, message):
print 'received msg:', `message`
ad = adtwist('/dev/ttyU1', baudrate=115200)
ad.on_message += msgcbfun
reactor.run()
This will create an AlarmDecoder instance (from alarmdecoder) and attach
it to the device /dev/ttyU1
. It will print each message received from
the device.