panda/tests/automated/5_wifi_functionality.py

70 lines
1.8 KiB
Python
Raw Normal View History

2017-07-30 09:26:48 -06:00
import time
from panda import Panda
from .helpers import start_heartbeat_thread, reset_pandas, time_many_sends, connect_wifi, test_white, panda_type_to_serial
# Reset the pandas before running tests
def aaaa_reset_before_tests():
reset_pandas()
2017-07-30 09:26:48 -06:00
@test_white
@panda_type_to_serial
def test_get_serial_wifi(serials=None):
connect_wifi(serials[0])
2017-08-29 12:01:24 -06:00
2017-07-30 09:26:48 -06:00
p = Panda("WIFI")
print(p.get_serial())
@test_white
@panda_type_to_serial
def test_throughput(serials=None):
connect_wifi(serials[0])
p = Panda(serials[0])
2017-07-30 09:26:48 -06:00
# Start heartbeat
start_heartbeat_thread(p)
2017-07-30 09:26:48 -06:00
# enable output mode
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
# enable CAN loopback mode
p.set_can_loopback(True)
p = Panda("WIFI")
for speed in [100, 250, 500, 750, 1000]:
2017-07-30 09:26:48 -06:00
# set bus 0 speed to speed
p.set_can_speed_kbps(0, speed)
time.sleep(0.1)
2017-07-30 09:26:48 -06:00
comp_kbps = time_many_sends(p, 0)
# bit count from https://en.wikipedia.org/wiki/CAN_bus
saturation_pct = (comp_kbps / speed) * 100.0
2017-07-30 09:26:48 -06:00
#assert_greater(saturation_pct, 80)
#assert_less(saturation_pct, 100)
print("WIFI loopback 100 messages at speed %d, comp speed is %.2f, percent %.2f" % (speed, comp_kbps, saturation_pct))
@test_white
@panda_type_to_serial
def test_recv_only(serials=None):
connect_wifi(serials[0])
p = Panda(serials[0])
# Start heartbeat
start_heartbeat_thread(p)
2017-08-12 19:03:45 -06:00
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
Black (#254) * late usb * Added type support for black panda * Added harness presence and orientation detection * harness relay driving code * Added intercept support in black panda code. Switched around can0 and can2 * Disable ADCs after orientation detection. Ignition interrupts via harness * WIP: Hardware abstraction layer + black panda bringup * Fixed bootstub build * Fixed bootstub for pedal * Fixed infinite loops * Got CAN buses working on white again * Fixed pedal build and black can interfaces * Got CAN buses working on black panda * Finished loopback test for black panda * Erase all flash sectors on the panda. Increased binary limit. Added extra python functions. * Fixed python * Made new code MISRA compliant * Cleaned up ignition. Fixed build * Fixed health packet * Fixed CAN mode on black bug. Changed OBD to switch on ELM mode * Fixes from Github review * Fixed MISRA issue for pedal * Fixed failing gmlan tests * ELM327 safety: allow diagnostic on all buses * Cleaned up EON relay code * delete only 3 sectors instead of 11 to allow a new build to be flashed. Much faster to flash * Removed CAN only can0 output mode. Does not make sense on black panda due to reversibility issues. * Added heartbeat logic for EON code on panda. Go to NOOUTPUT if EON does not send a heartbeat for 5 seconds. * Remove all CAN buses live on EON startup. Shouldn't be necessary to have this separate case * Formatting * Added file I forgot to push * Added heartbeat to testing code to make sure EON tests don't fail. Should probably find a better way to do this though. Heartbeat thread didn't work, concurrent USB connection issues... * Safety: support black panda for Honda Bosch * Disable OBD2 if setting to NOOUTPUT mode * Run safety tests for all hw_types * Fail test if subtest fails * fix safety tests
2019-07-23 16:07:06 -06:00
2017-08-12 19:03:45 -06:00
p.set_can_loopback(True)
pwifi = Panda("WIFI")
# TODO: msg_count=1000 drops packets, is this fixable?
for msg_count in [10, 100, 200]:
2017-08-12 19:03:45 -06:00
speed = 500
p.set_can_speed_kbps(0, speed)
comp_kbps = time_many_sends(p, 0, pwifi, msg_count)
saturation_pct = (comp_kbps / speed) * 100.0
2017-08-12 19:03:45 -06:00
print("HT WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f" % (msg_count, speed, comp_kbps, saturation_pct))