2019-09-25 08:50:53 +08:00
|
|
|
#!/usr/bin/env python3
|
2017-04-28 03:08:03 +08:00
|
|
|
import struct
|
2017-04-28 02:32:14 +08:00
|
|
|
import time
|
2017-06-14 09:50:47 +08:00
|
|
|
|
2023-08-15 03:52:02 +08:00
|
|
|
from panda import Panda
|
2017-04-18 22:34:56 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-12-07 06:39:28 +08:00
|
|
|
p = Panda()
|
2019-09-25 09:07:05 +08:00
|
|
|
print(p.get_serial())
|
|
|
|
print(p.health())
|
2017-05-03 14:25:54 +08:00
|
|
|
|
|
|
|
t1 = time.time()
|
2023-08-07 05:59:22 +08:00
|
|
|
for _ in range(100):
|
2017-05-03 14:25:54 +08:00
|
|
|
p.get_serial()
|
|
|
|
t2 = time.time()
|
2020-06-01 16:49:26 +08:00
|
|
|
print("100 requests took %.2f ms" % ((t2 - t1) * 1000))
|
2017-05-03 14:25:54 +08:00
|
|
|
|
2018-02-15 07:34:42 +08:00
|
|
|
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
|
2017-04-18 22:34:56 +08:00
|
|
|
|
2017-04-28 03:08:03 +08:00
|
|
|
a = 0
|
2017-06-14 09:50:47 +08:00
|
|
|
while True:
|
2017-04-28 02:32:14 +08:00
|
|
|
# flood
|
2020-06-01 16:49:26 +08:00
|
|
|
msg = b"\xaa" * 4 + struct.pack("I", a)
|
2017-04-28 03:08:03 +08:00
|
|
|
p.can_send(0xaa, msg, 0)
|
|
|
|
p.can_send(0xaa, msg, 1)
|
|
|
|
p.can_send(0xaa, msg, 4)
|
2017-04-28 02:32:14 +08:00
|
|
|
time.sleep(0.01)
|
|
|
|
|
2017-04-29 08:25:37 +08:00
|
|
|
dat = p.can_recv()
|
|
|
|
if len(dat) > 0:
|
2017-06-14 09:50:47 +08:00
|
|
|
print(dat)
|
2017-04-28 03:08:03 +08:00
|
|
|
a += 1
|