-
Notifications
You must be signed in to change notification settings - Fork 0
/
lockout_msg.py
43 lines (34 loc) · 946 Bytes
/
lockout_msg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# Show/hide "update required" screen.
# Required artoo 0.7.0 or later.
import socket
import struct
import sys
UNLOCK = 0
LOCK = 1
# Must match flightcode/stm32
LOCKOUT_STATE_PORT = 5020
def send(lock_state):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
msg = struct.pack("!B", lock_state)
s.sendto(msg, ("127.0.0.1", LOCKOUT_STATE_PORT))
s.close()
def send_lock():
send(LOCK)
def send_unlock():
send(UNLOCK)
def usage():
print "usage: lockout_msg.py <lockout>"
print " where <lockout> is one of"
print " lock show \"update required\" screen"
print " unlock hide \"update required\" screen"
if __name__ == "__main__":
# one required argument: "lock" or "unlock"
if len(sys.argv) != 2:
usage()
elif sys.argv[1] == "lock":
send_lock()
elif sys.argv[1] == "unlock":
send_unlock()
else:
usage()