-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (49 loc) · 1.81 KB
/
main.py
File metadata and controls
60 lines (49 loc) · 1.81 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
import sys
from modules.tx import *
from modules.rx import *
from modules.txrx import *
from modules.sendmsg import *
from modules.getmsg import *
def usage():
print("Usage:")
print("\t{} path_to_json".format(sys.argv[0]))
def check_args():
# we excpect a single command-line argument - path to json
if len(sys.argv) < 2:
print("-E- missing json argument")
usage()
exit()
def load_mission():
global mission_steps; mission_steps = []
global sock
with open(sys.argv[1]) as json_file:
mission = json.load(json_file)
modem = mission["modem"]
port = mission["port"]
sock = UnetSocket(modem, port)
for step in mission["steps"]:
stepObj = create_task(step)
if stepObj:
mission_steps.append(stepObj)
def create_task(step):
type = step["type"].lower()
if type == "tx":
return Tx(sock, step["signal"], step["power_level"], step["number_of_loops"], step["sleep_between_loops"], step["fc"])
elif type == "rx":
print(str(step))
return Rx(sock, step["number_of_recs"], step["rec_size"], step["rx_out_folder"], step["rx_out_file"], step["sleep_between_loops"])
elif type == "txrx":
return TxRx(sock, step["signal"], step["power_level"], step["number_of_loops"], step["sleep_between_loops"], step["fc"], step["rec_size"], step["rx_out_folder"], step["rx_out_file"])
elif type == "sendmsg":
return SendMsg(sock, step["recipient"], step["power_level"], step["text"], step["number_of_loops"], step["sleep_between_loops"])
elif type == "getmsg":
return GetMsg(sock)
else:
return None
if __name__ == "__main__":
check_args()
load_mission()
for step in mission_steps:
step.id()
step.exec_step()