2019-09-24 18:50:53 -06:00
|
|
|
#!/usr/bin/env python3
|
2017-04-18 08:34:56 -06:00
|
|
|
import os
|
2017-06-13 19:50:47 -06:00
|
|
|
import sys
|
2017-04-27 13:08:03 -06:00
|
|
|
import struct
|
2017-04-27 12:32:14 -06:00
|
|
|
import time
|
2017-06-13 19:50:47 -06:00
|
|
|
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
|
|
|
from panda import Panda
|
2017-04-18 08:34:56 -06:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if os.getenv("WIFI") is not None:
|
|
|
|
p = Panda("WIFI")
|
|
|
|
else:
|
|
|
|
p = Panda()
|
2019-09-24 19:02:15 -06:00
|
|
|
print((p.get_serial()))
|
|
|
|
print((p.health()))
|
2017-05-03 00:25:54 -06:00
|
|
|
|
|
|
|
t1 = time.time()
|
|
|
|
for i in range(100):
|
|
|
|
p.get_serial()
|
|
|
|
t2 = time.time()
|
2019-09-24 19:02:15 -06:00
|
|
|
print(("100 requests took %.2f ms" % ((t2-t1)*1000)))
|
2017-05-03 00:25:54 -06:00
|
|
|
|
2018-02-14 16:34:42 -07:00
|
|
|
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
|
2017-04-18 08:34:56 -06:00
|
|
|
|
2017-04-27 13:08:03 -06:00
|
|
|
a = 0
|
2017-06-13 19:50:47 -06:00
|
|
|
while True:
|
2017-04-27 12:32:14 -06:00
|
|
|
# flood
|
2017-06-13 19:50:47 -06:00
|
|
|
msg = b"\xaa"*4 + struct.pack("I", a)
|
2017-04-27 13:08:03 -06:00
|
|
|
p.can_send(0xaa, msg, 0)
|
|
|
|
p.can_send(0xaa, msg, 1)
|
|
|
|
p.can_send(0xaa, msg, 4)
|
2017-04-27 12:32:14 -06:00
|
|
|
time.sleep(0.01)
|
|
|
|
|
2017-04-28 18:25:37 -06:00
|
|
|
dat = p.can_recv()
|
|
|
|
if len(dat) > 0:
|
2017-06-13 19:50:47 -06:00
|
|
|
print(dat)
|
2017-04-27 13:08:03 -06:00
|
|
|
a += 1
|