Created
April 18, 2018 08:05
-
-
Save foxel/6a27ad0b300cb6164c537c6004c3affe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
import sys | |
# assuming you have https://github.com/foxel/noolite-mqtt-python near | |
from noolite_serial import NooLiteSerial | |
noo_serial = NooLiteSerial('/dev/ttyS0') | |
if len(sys.argv) < 3: | |
raise Exception('Not Enough params. Usage: noo.py [ch] [cmd]') | |
noo_serial.send_command(int(sys.argv[1]), int(sys.argv[2]), 2) | |
# ждем ответа | |
exit = false | |
while not exit: # резонно добавить ограничение по времени ожидания | |
# first receive packets from noolite serial | |
packets = noo_serial.receive() | |
for packet in packets: | |
mode = ord(packet[1]) | |
rch = ord(packet[4]) | |
cmd = ord(packet[5]) | |
if mode == 2 and cmd == 130 and ch == rch: # это статус от нашего канала | |
print packet | |
exit = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment