build_relay.py 368 Bytes
Newer Older
Daniel STAN's avatar
Daniel STAN committed
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python3

import sys

on = {'on': True, 'off': False}[sys.argv[1]]

channel = int(sys.argv[2])

port = int(sys.argv[3])

Daniel STAN's avatar
Daniel STAN committed
11
print("Sending %s to port %d of channel %d" % (('on' if on else 'off'), port, channel), file=sys.stderr)
Daniel STAN's avatar
Daniel STAN committed
12 13 14 15 16 17 18

code = 0b010101010101010101010101
code ^= 1<<(2*(4-channel)+16)
code ^= 1<<(2*(4-port)+8)
if not on:
    code ^= 1
print(code)