-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_sm.py
More file actions
34 lines (28 loc) · 978 Bytes
/
Copy pathdebug_sm.py
File metadata and controls
34 lines (28 loc) · 978 Bytes
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
import time
from acc_shared_memory import ACCSharedMemory
def debug():
sm = ACCSharedMemory()
if not sm.open():
print("Could not open ACC Shared Memory.")
return
print("Reading ACC Shared Memory... (Ctrl+C to stop)")
try:
last_p_id = -1
last_g_id = -1
while True:
p = sm.read_physics()
g = sm.read_graphics()
if p.packet_id != last_p_id or g.packet_id != last_g_id:
print(f"P_ID={p.packet_id} G_ID={g.packet_id} STATUS={g.status} RPM={p.rpms} V={p.speed_kmh:.1f} LAP={g.current_time_ms}ms")
last_p_id = p.packet_id
last_g_id = g.packet_id
else:
# Still printing to show it's alive, but values are same
pass
time.sleep(0.1)
except KeyboardInterrupt:
print("\nStopped.")
finally:
sm.close()
if __name__ == "__main__":
debug()