2024-06-11 01:36:40 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import struct
|
|
|
|
import time
|
|
|
|
|
2025-03-08 09:09:31 +00:00
|
|
|
from opendbc.car.structs import CarParams
|
2024-06-11 01:36:40 +00:00
|
|
|
from panda import Panda
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
p = Panda()
|
|
|
|
print(p.get_serial())
|
|
|
|
print(p.health())
|
|
|
|
|
|
|
|
t1 = time.time()
|
|
|
|
for _ in range(100):
|
|
|
|
p.get_serial()
|
|
|
|
t2 = time.time()
|
|
|
|
print("100 requests took %.2f ms" % ((t2 - t1) * 1000))
|
|
|
|
|
2025-03-08 09:09:31 +00:00
|
|
|
p.set_safety_mode(CarParams.SafetyModel.allOutput)
|
2024-06-11 01:36:40 +00:00
|
|
|
|
|
|
|
a = 0
|
|
|
|
while True:
|
|
|
|
# flood
|
|
|
|
msg = b"\xaa" * 4 + struct.pack("I", a)
|
|
|
|
p.can_send(0xaa, msg, 0)
|
|
|
|
p.can_send(0xaa, msg, 1)
|
|
|
|
p.can_send(0xaa, msg, 4)
|
|
|
|
time.sleep(0.01)
|
|
|
|
|
|
|
|
dat = p.can_recv()
|
|
|
|
if len(dat) > 0:
|
|
|
|
print(dat)
|
|
|
|
a += 1
|