Skip to content

Instantly share code, notes, and snippets.

@foxel
Created April 18, 2018 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxel/6a27ad0b300cb6164c537c6004c3affe to your computer and use it in GitHub Desktop.
Save foxel/6a27ad0b300cb6164c537c6004c3affe to your computer and use it in GitHub Desktop.
#!/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