-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (31 loc) · 1020 Bytes
/
main.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
#!/usr/bin/env python
import messages
import vw_conf
import time
import datetime
exit = False
while not exit:
line = raw_input("> ")
response = None
if line == "exit":
exit = True
elif line == "get time":
response = messages.send_and_receive(messages.time_req(0))
elif line == "set time":
now = int(time.mktime(datetime.datetime.now().timetuple()))
response = messages.send_and_receive(messages.time_req(now))
elif line.startswith("read "):
args = line.split(" ")
pin = int(args[1])
response = messages.send_and_receive(messages.analog_read_req(pin))
elif line.startswith("blink "):
args = line.split(" ")
pin = int(args[1])
ms = int(args[2])
response = messages.send_and_receive(messages.blink_req(pin, ms))
elif line == "dht":
response = messages.send_and_receive(messages.dht22_req())
else:
print("Wrong command")
if response:
print("Got "+str(response))