-
Notifications
You must be signed in to change notification settings - Fork 0
/
control_asynchronous_test.py
38 lines (29 loc) · 997 Bytes
/
control_asynchronous_test.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
import asyncio
import time
async def run_print(text):
#while(True):
print(text)
time.sleep(1)
async def run_wait_for_cmd():
#while (True):
cmd = input()
if(cmd[2].isdigit()):
if(cmd[0] == "S"): # SERVO COMMAND -- data count: 1 {0,1,2,3,4} - {up, down, left, right, default}
print("Received command for Servo: " ,cmd[2])
elif (cmd[0] == "M"): # MOVEMENT COMMAND -- data count: 1 {0,1,2,3} - {forward, backward, left, right}
print("Received command for Movement: ", cmd[2])
elif (cmd[0] == "C"): # SETTINGS COMMAND
print("Received command for Setings: ", cmd[2])
else:
print("Wrong command format")
else:
print("Wrong command format")
async def main():
while(True):
await asyncio.gather(
run_print("Test text"),
run_wait_for_cmd()
)
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())