1#!/usr/bin/python3 2 3import sys 4import serial 5 6mode = sys.argv[1] 7relay = sys.argv[2] 8 9# our relays are "off" means "board is powered". 10mode_swap = { 11 "on": "off", 12 "off": "on", 13} 14mode = mode_swap[mode] 15 16ser = serial.Serial('/dev/ttyACM0', 115200, timeout=2) 17command = "relay {} {}\n\r".format(mode, relay) 18ser.write(command.encode()) 19ser.close() 20