summaryrefslogtreecommitdiff
path: root/.gitlab-ci/bare-metal/google-power-relay.py
blob: 52ed6f5e48f6c79206471b523f755cd512dba609 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python3

import sys
import serial

mode = sys.argv[1]
relay = sys.argv[2]

# our relays are "off" means "board is powered".
mode_swap = {
    "on": "off",
    "off": "on",
}
mode = mode_swap[mode]

ser = serial.Serial('/dev/ttyACM0', 115200, timeout=2)
command = "relay {} {}\n\r".format(mode, relay)
ser.write(command.encode())
ser.close()