panda/tests/standalone_test.py

37 lines
664 B
Python
Raw Normal View History

2017-04-18 08:34:56 -06:00
#!/usr/bin/env python
import os
2017-04-27 13:08:03 -06:00
import struct
2017-04-27 12:32:14 -06:00
import time
2017-04-27 13:08:03 -06:00
from panda.lib.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()
2017-04-28 18:25:37 -06:00
print p.get_serial()
2017-05-03 18:34:45 -06:00
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()
print "100 requests took %.2f ms" % ((t2-t1)*1000)
2017-05-02 00:40:49 -06:00
p.set_controls_allowed(True)
2017-04-18 08:34:56 -06:00
2017-04-27 13:08:03 -06:00
a = 0
2017-04-27 12:32:14 -06:00
while 1:
# flood
2017-04-27 13:08:03 -06:00
msg = "\xaa"*4 + struct.pack("I", a)
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:
print dat
2017-04-27 13:08:03 -06:00
a += 1
2017-04-27 12:32:14 -06:00