-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestserial.py
More file actions
64 lines (49 loc) · 1.28 KB
/
Copy pathtestserial.py
File metadata and controls
64 lines (49 loc) · 1.28 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
61
62
63
64
import glob, time
from trunk import *
result = ''
last_result = ''
result2 = ''
last_result2 = ''
start = time.time()
end = 0
start2 = time.time()
end2 = 0
if get_Setting('mainLoopStatus', 'status.json', 0) == "closed":
print("Warning: Manual override enabled")
set_Setting('mainLoopStatus', 'manual', 'status.json', 1)
while 1 :
result = glob.glob('/dev/ttyA*')
#print(len(result))
#print(result.find("/dev/ttyACM1"))
found_ACM1 = 0
found_ACM2 = 0
for x in result:
if x.find("/dev/ttyACM1") >= 0:
found_ACM1 = 1
elif x.find("/dev/ttyACM2") >= 0:
found_ACM2 = 1
if found_ACM1 == 1 :
#print("/dev/ttyACM1")
result = "/dev/ttyACM1 Connected"
else:
#print("Disconnected")
result = "/dev/ttyACM1 Disconnected"
if found_ACM2 == 1 :
#print("/dev/ttyACM1")
result2 = "/dev/ttyACM2 Connected"
else:
#print("Disconnected")
result2 = "/dev/ttyACM2 Disconnected"
if last_result != result :
end = time.time()
print("[" + str(round(end - start,2)) + "] " + result)
last_result = result
start = time.time()
if last_result2 != result2 :
end = time.time()
print("[" + str(round(end - start,0)) + "] " + result2)
last_result2 = result2
start = time.time()
time.sleep(.1)
if get_Setting('mainLoopStatus', 'status.json', 0) == "closed":
break