17ec681f3Smrg#!/usr/bin/python3 27ec681f3Smrg 37ec681f3Smrgimport sys 47ec681f3Smrgimport serial 57ec681f3Smrg 67ec681f3Smrgmode = sys.argv[1] 77ec681f3Smrgrelay = sys.argv[2] 87ec681f3Smrg 97ec681f3Smrg# our relays are "off" means "board is powered". 107ec681f3Smrgmode_swap = { 117ec681f3Smrg "on" : "off", 127ec681f3Smrg "off" : "on", 137ec681f3Smrg} 147ec681f3Smrgmode = mode_swap[mode] 157ec681f3Smrg 167ec681f3Smrgser = serial.Serial('/dev/ttyACM0', 115200, timeout=2) 177ec681f3Smrgcommand = "relay {} {}\n\r".format(mode, relay) 187ec681f3Smrgser.write(command.encode()) 197ec681f3Smrgser.close() 20