Example #1
0
def test_udp_doesnt_drop():
    connect_wifi()

    p = Panda()
    p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
    p.set_can_loopback(True)

    pwifi = PandaWifiStreaming()
    while 1:
        if len(pwifi.can_recv()) == 0:
            break

    for msg_count in [1, 100]:
        for i in range({1: 0x80, 100: 0x20}[msg_count]):
            pwifi.kick()

            speed = 500
            p.set_can_speed_kbps(0, speed)
            comp_kbps = time_many_sends(p,
                                        0,
                                        pwifi,
                                        msg_count=msg_count,
                                        msg_id=0x100 + i)
            saturation_pct = (comp_kbps / speed) * 100.0

            if msg_count == 1:
                sys.stdout.write(".")
                sys.stdout.flush()
            else:
                print(
                    "UDP WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f"
                    % (msg_count, speed, comp_kbps, saturation_pct))
                assert_greater(saturation_pct, 40)
                assert_less(saturation_pct, 100)
        print("")
Example #2
0
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             ".."))
from panda import Panda, PandaWifiStreaming

# test throughput between USB and wifi

if __name__ == "__main__":
    print(Panda.list())
    p_out = Panda("108018800f51363038363036")
    print(p_out.get_serial())
    #p_in = Panda("02001b000f51363038363036")
    p_in = Panda("WIFI")
    print(p_in.get_serial())

    p_in = PandaWifiStreaming()  # type: ignore

    #while True:
    #  p_in.can_recv()
    #sys.exit(0)

    p_out.set_safety_mode(Panda.SAFETY_ALLOUTPUT)

    set_out, set_in = set(), set()

    # drain
    p_out.can_recv()
    p_in.can_recv()

    BATCH_SIZE = 16
    for a in tqdm(list(range(0, 10000, BATCH_SIZE))):
Example #3
0
def test_udp_doesnt_drop(serials=None):
    connect_wifi(serials[0])

    p = Panda(serials[0])
    p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
    p.set_can_loopback(True)

    pwifi = PandaWifiStreaming()
    while 1:
        if len(pwifi.can_recv()) == 0:
            break

    for msg_count in [1, 100]:
        saturation_pcts = []
        for i in range({1: 0x80, 100: 0x20}[msg_count]):
            pwifi.kick()

            speed = 500
            p.set_can_speed_kbps(0, speed)
            comp_kbps = time_many_sends(p,
                                        0,
                                        pwifi,
                                        msg_count=msg_count,
                                        msg_id=0x100 + i)
            saturation_pct = (comp_kbps / speed) * 100.0

            if msg_count == 1:
                sys.stdout.write(".")
                sys.stdout.flush()
            else:
                print(
                    "UDP WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f"
                    % (msg_count, speed, comp_kbps, saturation_pct))
                assert_greater(saturation_pct,
                               20)  #sometimes the wifi can be slow...
                assert_less(saturation_pct, 100)
                saturation_pcts.append(saturation_pct)
        if len(saturation_pcts) > 0:
            assert_greater(sum(saturation_pcts) / len(saturation_pcts), 60)

    time.sleep(5)
    usb_ok_cnt = 0
    REQ_USB_OK_CNT = 500
    st = time.time()
    msg_id = 0x1bb
    bus = 0
    last_missing_msg = 0
    while usb_ok_cnt < REQ_USB_OK_CNT and (time.time() - st) < 40:
        p.can_send(msg_id, "message", bus)
        time.sleep(0.01)
        r = [1]
        missing = True
        while len(r) > 0:
            r = p.can_recv()
            r = filter(lambda x: x[3] == bus and x[0] == msg_id, r)
            if len(r) > 0:
                missing = False
                usb_ok_cnt += len(r)
            if missing:
                last_missing_msg = time.time()
    et = time.time() - st
    last_missing_msg = last_missing_msg - st
    print(
        "waited {} for panda to recv can on usb, {} msgs, last missing at {}".
        format(et, usb_ok_cnt, last_missing_msg))
    assert usb_ok_cnt >= REQ_USB_OK_CNT, "Unable to recv can on USB after UDP"
Example #4
0
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             ".."))
from panda import Panda, PandaWifiStreaming

# test throughput between USB and wifi

if __name__ == "__main__":
    print(Panda.list())
    p_out = Panda("108018800f51363038363036")
    print(p_out.get_serial())
    #p_in = Panda("02001b000f51363038363036")
    p_in = Panda("WIFI")
    print(p_in.get_serial())

    p_in = PandaWifiStreaming()

    #while True:
    #  p_in.can_recv()
    #sys.exit(0)

    p_out.set_controls_allowed(True)

    set_out, set_in = set(), set()

    # drain
    p_out.can_recv()
    p_in.can_recv()

    BATCH_SIZE = 16
    for a in tqdm(range(0, 10000, BATCH_SIZE)):