Files
panda-meb/scripts/standalone_test.py

34 lines
655 B
Python
Raw Normal View History

2019-09-24 17:50:53 -07:00
#!/usr/bin/env python3
2017-04-27 12:08:03 -07:00
import struct
2017-04-27 11:32:14 -07:00
import time
from opendbc.car.structs import CarParams
2023-08-14 12:52:02 -07:00
from panda import Panda
2017-04-18 07:34:56 -07:00
if __name__ == "__main__":
p = Panda()
2019-09-24 18:07:05 -07:00
print(p.get_serial())
print(p.health())
2017-05-02 23:25:54 -07:00
t1 = time.time()
2023-08-06 14:59:22 -07:00
for _ in range(100):
2017-05-02 23:25:54 -07:00
p.get_serial()
t2 = time.time()
print("100 requests took %.2f ms" % ((t2 - t1) * 1000))
2017-05-02 23:25:54 -07:00
p.set_safety_mode(CarParams.SafetyModel.allOutput)
2017-04-18 07:34:56 -07:00
2017-04-27 12:08:03 -07:00
a = 0
while True:
2017-04-27 11:32:14 -07:00
# flood
msg = b"\xaa" * 4 + struct.pack("I", a)
2017-04-27 12:08:03 -07:00
p.can_send(0xaa, msg, 0)
p.can_send(0xaa, msg, 1)
p.can_send(0xaa, msg, 4)
2017-04-27 11:32:14 -07:00
time.sleep(0.01)
2017-04-28 17:25:37 -07:00
dat = p.can_recv()
if len(dat) > 0:
print(dat)
2017-04-27 12:08:03 -07:00
a += 1