Squashed 'panda/' changes from 9881e6118..30c7ca8a5

30c7ca8a5 bump version to 1.5.3
9403dbebe Need to fix wifi test before re-enabling.
0812362b5 GPS UART fix until boardd is refactored (#294)
ffbdb87a8 python2 -> 3 fixes to pedal flasher (#292)
78b75ef59 Added build type to release version strings
736c2cbf7 Fixed sending of bytes over PandaSerial
0894b28f1 Fixed USB power mode on black (#291)
4b3358c92 patch to be able to switch from EON to PC with a Panda that has EON b… (#290)
a95c44a71 Made setting of NOOUTPUT on no heartbeat more efficient (#287)
948683688 UART instability fix with high interrupt load (#283)
9a9e9d47b Fix usb_power_mode missing initialization (#289)
af0960ad3 DFU fix (#288)
70219d7bb match safety enum in cereal (#285)
a338d3932 Fix build for jenkins test
78ef4a6eb Stop charge (#284)
5266a4028 Fix typo (#286)
f4787ec5a Revert "turn on CDP when ignition switches on (#281)"
d37daee97 Revert "NONE and CLIENT should be the same thing in white/grey pandas"
e97b283e7 NONE and CLIENT should be the same thing in white/grey pandas
8c1df559f turn on CDP when ignition switches on (#281)
847a35d42 Fix bullet points
fac027716 Misra update (#280)
5a04df6b1 Added description of regression tests to README
c4aabae59 Fixed some python3 bugs in the test scripts and PandaSerial
9af0cb353 Bump version
c4ac3d63b Disable GPS load switching on black pandas
078ee588c This is the correct table, actually
578b95ee3 Misra table of coverage added
d383a2625 bump panda
b98ca010d fix sdk build in python3 env (#279)
63d3dc7d3 Set python3 env before runnign get_sdk, so we know if it fails
e951d79c0 legacy code we don't control can remain python2
11b715118 Merge pull request #276 from commaai/python3
9893a842a Merge pull request #277 from zorrobyte/patch-1
d3268690c Revert "revert back esptool to python2 and force to build esptools with python2"
875e76012 revert back esptool to python2 and force to build esptools with python2
9c40e6240 needed to install python3
ed2ac87cf Also moved safety tests to python3
6842b2d2c move esptool sdk installation before python3 env is set. Kind of a cheat
b5a2cabcd this hopefully fixes build test
628050955 Fixes safety replay
2c220b623 this fixes language regr test
fdbe789b8 use python 3 in Docker container
ee1ae4f86 Better hash print
0de9ef73c Revert "Final 2to3 on the whole repo"
c92fd3bc9 Final 2to3 on the whole repo
5f2bc4460 better
b2a30fdbd make works!
b74005d10 fix sign.py
fe727706b read file as byte and no tab before sleep
32a344ef6 Update README.md
2dc34096a 2to3 applied
ffa68ef71 undo unnecessary brackets for print
dbc248027 Fix all the prints with 2to3, some need to be undo
5a7aeba0f xrange is gone
982c4c928 one more python3 env
1e2412a29 env python -> env python3

git-subtree-dir: panda
git-subtree-split: 30c7ca8a53a3adb05d23d7cfe64fb716a656ef1a
This commit is contained in:
Vehicle Researcher
2019-10-09 18:31:56 +00:00
parent 876256a268
commit 38faf7f8a4
98 changed files with 1314 additions and 796 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
#!/usr/bin/python
#!/usr/bin/env python3
import requests
import json
from automated.helpers import _connect_wifi
from .automated.helpers import _connect_wifi
from panda import Panda
from nose.tools import assert_equal
@@ -12,12 +12,12 @@ if __name__ == "__main__":
for p in Panda.list():
dongle_id, pw = Panda(p).get_serial()
print dongle_id, pw
print(dongle_id, pw)
assert(dongle_id.isalnum())
_connect_wifi(dongle_id, pw)
r = requests.get("http://192.168.0.10/")
print r.text
print(r.text)
wifi_dongle_id = r.text.split("ssid: panda-")[1].split("<br/>")[0]
st_version = r.text.split("st version:")[1].strip().split("<br/>")[0]
esp_version = r.text.split("esp version:")[1].strip().split("<br/>")[0]
+1 -1
View File
@@ -1,6 +1,6 @@
import os
from panda import Panda
from helpers import panda_type_to_serial, test_white_and_grey, test_all_pandas, panda_connect_and_init
from .helpers import panda_type_to_serial, test_white_and_grey, test_all_pandas, panda_connect_and_init
@test_all_pandas
@panda_connect_and_init
+14 -14
View File
@@ -1,10 +1,10 @@
from __future__ import print_function
import os
import sys
import time
from panda import Panda
from nose.tools import assert_equal, assert_less, assert_greater
from helpers import SPEED_NORMAL, SPEED_GMLAN, time_many_sends, test_white_and_grey, panda_type_to_serial, test_all_pandas, panda_connect_and_init
from .helpers import SPEED_NORMAL, SPEED_GMLAN, time_many_sends, test_white_and_grey, panda_type_to_serial, test_all_pandas, panda_connect_and_init
@test_all_pandas
@panda_connect_and_init
@@ -25,19 +25,19 @@ def test_can_loopback(p):
p.set_can_speed_kbps(bus, 250)
# send a message on bus 0
p.can_send(0x1aa, "message", bus)
p.can_send(0x1aa, b"message", bus)
# confirm receive both on loopback and send receipt
time.sleep(0.05)
r = p.can_recv()
sr = filter(lambda x: x[3] == 0x80 | bus, r)
lb = filter(lambda x: x[3] == bus, r)
sr = [x for x in r if x[3] == 0x80 | bus]
lb = [x for x in r if x[3] == bus]
assert len(sr) == 1
assert len(lb) == 1
# confirm data is correct
assert 0x1aa == sr[0][0] == lb[0][0]
assert "message" == sr[0][2] == lb[0][2]
assert b"message" == sr[0][2] == lb[0][2]
@test_all_pandas
@panda_connect_and_init
@@ -49,7 +49,7 @@ def test_safety_nooutput(p):
p.set_can_loopback(True)
# send a message on bus 0
p.can_send(0x1aa, "message", 0)
p.can_send(0x1aa, b"message", 0)
# confirm receive nothing
time.sleep(0.05)
@@ -67,8 +67,8 @@ def test_reliability(p):
p.set_can_loopback(True)
p.set_can_speed_kbps(0, 1000)
addrs = range(100, 100+MSG_COUNT)
ts = [(j, 0, "\xaa"*8, 0) for j in addrs]
addrs = list(range(100, 100+MSG_COUNT))
ts = [(j, 0, b"\xaa"*8, 0) for j in addrs]
# 100 loops
for i in range(LOOP_COUNT):
@@ -80,11 +80,11 @@ def test_reliability(p):
while len(r) < 200 and (time.time() - st) < 0.5:
r.extend(p.can_recv())
sent_echo = filter(lambda x: x[3] == 0x80, r)
loopback_resp = filter(lambda x: x[3] == 0, r)
sent_echo = [x for x in r if x[3] == 0x80]
loopback_resp = [x for x in r if x[3] == 0]
assert_equal(sorted(map(lambda x: x[0], loopback_resp)), addrs)
assert_equal(sorted(map(lambda x: x[0], sent_echo)), addrs)
assert_equal(sorted([x[0] for x in loopback_resp]), addrs)
assert_equal(sorted([x[0] for x in sent_echo]), addrs)
assert_equal(len(r), 200)
# take sub 20ms
@@ -182,4 +182,4 @@ def test_gmlan_bad_toggle(p):
def test_serial_debug(p):
junk = p.serial_read(Panda.SERIAL_DEBUG)
p.call_control_api(0xc0)
assert(p.serial_read(Panda.SERIAL_DEBUG).startswith("can "))
assert(p.serial_read(Panda.SERIAL_DEBUG).startswith(b"can "))
+2 -2
View File
@@ -1,8 +1,8 @@
from __future__ import print_function
import os
import time
from panda import Panda
from helpers import connect_wifi, test_white, test_all_pandas, panda_type_to_serial, panda_connect_and_init
from .helpers import connect_wifi, test_white, test_all_pandas, panda_type_to_serial, panda_connect_and_init
import requests
@test_all_pandas
+2 -2
View File
@@ -1,7 +1,7 @@
from __future__ import print_function
import time
from panda import Panda
from helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial
from .helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial
from nose.tools import timed, assert_equal, assert_less, assert_greater
@test_white
+3 -3
View File
@@ -1,7 +1,7 @@
from __future__ import print_function
import sys
import time
from helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial
from .helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial
from panda import Panda, PandaWifiStreaming
from nose.tools import timed, assert_equal, assert_less, assert_greater
@@ -54,7 +54,7 @@ def test_udp_doesnt_drop(serials=None):
missing = True
while len(r) > 0:
r = p.can_recv()
r = filter(lambda x: x[3] == bus and x[0] == msg_id, r)
r = [x for x in r if x[3] == bus and x[0] == msg_id]
if len(r) > 0:
missing = False
usb_ok_cnt += len(r)
+9 -9
View File
@@ -1,10 +1,10 @@
from __future__ import print_function
import os
import time
import random
from panda import Panda
from nose.tools import assert_equal, assert_less, assert_greater
from helpers import time_many_sends, test_two_panda, test_two_black_panda, panda_type_to_serial, clear_can_buffers, panda_connect_and_init
from .helpers import time_many_sends, test_two_panda, test_two_black_panda, panda_type_to_serial, clear_can_buffers, panda_connect_and_init
@test_two_panda
@panda_type_to_serial
@@ -18,7 +18,7 @@ def test_send_recv(p_send, p_recv):
assert not p_send.legacy
assert not p_recv.legacy
p_send.can_send_many([(0x1ba, 0, "message", 0)]*2)
p_send.can_send_many([(0x1ba, 0, b"message", 0)]*2)
time.sleep(0.05)
p_recv.can_recv()
p_send.can_recv()
@@ -55,7 +55,7 @@ def test_latency(p_send, p_recv):
p_recv.set_can_speed_kbps(0, 100)
time.sleep(0.05)
p_send.can_send_many([(0x1ba, 0, "testmsg", 0)]*10)
p_send.can_send_many([(0x1ba, 0, b"testmsg", 0)]*10)
time.sleep(0.05)
p_recv.can_recv()
p_send.can_recv()
@@ -80,7 +80,7 @@ def test_latency(p_send, p_recv):
for i in range(num_messages):
st = time.time()
p_send.can_send(0x1ab, "message", bus)
p_send.can_send(0x1ab, b"message", bus)
r = []
while len(r) < 1 and (time.time() - st) < 5:
r = p_recv.can_recv()
@@ -127,7 +127,7 @@ def test_black_loopback(panda0, panda1):
panda1.set_can_loopback(False)
# clear stuff
panda0.can_send_many([(0x1ba, 0, "testmsg", 0)]*10)
panda0.can_send_many([(0x1ba, 0, b"testmsg", 0)]*10)
time.sleep(0.05)
panda0.can_recv()
panda1.can_recv()
@@ -155,7 +155,7 @@ def test_black_loopback(panda0, panda1):
def _test_buses(send_panda, recv_panda, _test_array):
for send_bus, send_obd, recv_obd, recv_buses in _test_array:
print("\nSend bus:", send_bus, " Send OBD:", send_obd, " Recv OBD:", recv_obd)
# set OBD on pandas
send_panda.set_gmlan(True if send_obd else None)
recv_panda.set_gmlan(True if recv_obd else None)
@@ -180,7 +180,7 @@ def test_black_loopback(panda0, panda1):
loop_buses.append(loop[3])
if len(cans_loop) == 0:
print(" No loop")
# test loop buses
recv_buses.sort()
loop_buses.sort()
@@ -192,4 +192,4 @@ def test_black_loopback(panda0, panda1):
print("***************** TESTING (0 --> 1) *****************")
_test_buses(panda0, panda1, test_array)
print("***************** TESTING (1 --> 0) *****************")
_test_buses(panda1, panda0, test_array)
_test_buses(panda1, panda0, test_array)
+16 -14
View File
@@ -2,9 +2,10 @@ import os
import sys
import time
import random
import binascii
import subprocess
import requests
import thread
import _thread
from functools import wraps
from panda import Panda
from nose.tools import timed, assert_equal, assert_less, assert_greater
@@ -49,7 +50,7 @@ def connect_wifi(serial=None):
FNULL = open(os.devnull, 'w')
def _connect_wifi(dongle_id, pw, insecure_okay=False):
ssid = str("panda-" + dongle_id)
ssid = "panda-" + dongle_id.decode("utf8")
r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT)
if not r:
@@ -75,7 +76,8 @@ def _connect_wifi(dongle_id, pw, insecure_okay=False):
print("WIFI: scanning %d" % cnt)
os.system("iwlist %s scanning > /dev/null" % wlan_interface)
os.system("nmcli device wifi rescan")
wifi_scan = filter(lambda x: ssid in x, subprocess.check_output(["nmcli","dev", "wifi", "list"]).split("\n"))
wifi_networks = [x.decode("utf8") for x in subprocess.check_output(["nmcli","dev", "wifi", "list"]).split(b"\n")]
wifi_scan = [x for x in wifi_networks if ssid in x]
if len(wifi_scan) != 0:
break
time.sleep(0.1)
@@ -140,7 +142,7 @@ def time_many_sends(p, bus, precv=None, msg_count=100, msg_id=None, two_pandas=F
raise ValueError("Cannot have two pandas that are the same panda")
st = time.time()
p.can_send_many([(msg_id, 0, "\xaa"*8, bus)]*msg_count)
p.can_send_many([(msg_id, 0, b"\xaa"*8, bus)]*msg_count)
r = []
r_echo = []
r_len_expected = msg_count if two_pandas else msg_count*2
@@ -153,11 +155,11 @@ def time_many_sends(p, bus, precv=None, msg_count=100, msg_id=None, two_pandas=F
while len(r_echo) < r_echo_len_exected and (time.time() - st) < 10:
r_echo.extend(p.can_recv())
sent_echo = filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r)
sent_echo.extend(filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r_echo))
resp = filter(lambda x: x[3] == bus and x[0] == msg_id, r)
sent_echo = [x for x in r if x[3] == 0x80 | bus and x[0] == msg_id]
sent_echo.extend([x for x in r_echo if x[3] == 0x80 | bus and x[0] == msg_id])
resp = [x for x in r if x[3] == bus and x[0] == msg_id]
leftovers = filter(lambda x: (x[3] != 0x80 | bus and x[3] != bus) or x[0] != msg_id, r)
leftovers = [x for x in r if (x[3] != 0x80 | bus and x[3] != bus) or x[0] != msg_id]
assert_equal(len(leftovers), 0)
assert_equal(len(resp), msg_count)
@@ -176,7 +178,7 @@ def panda_type_to_serial(fn):
if panda_type is not None:
if not isinstance(panda_type, list):
panda_type = [panda_type]
# If not done already, get panda serials and their type
global _panda_serials
if _panda_serials == None:
@@ -185,7 +187,7 @@ def panda_type_to_serial(fn):
p = Panda(serial=serial)
_panda_serials.append((serial, p.get_type()))
p.close()
# Find a panda with the correct types and add the corresponding serial
serials = []
for p_type in panda_type:
@@ -216,7 +218,7 @@ def panda_connect_and_init(fn):
if panda_serials is not None:
if not isinstance(panda_serials, list):
panda_serials = [panda_serials]
# Connect to pandas
pandas = []
for panda_serial in panda_serials:
@@ -230,7 +232,7 @@ def panda_connect_and_init(fn):
for bus, speed in [(0, SPEED_NORMAL), (1, SPEED_NORMAL), (2, SPEED_NORMAL), (3, SPEED_GMLAN)]:
panda.set_can_speed_kbps(bus, speed)
clear_can_buffers(panda)
thread.start_new_thread(heartbeat_thread, (panda,))
_thread.start_new_thread(heartbeat_thread, (panda,))
# Run test function
ret = fn(*pandas, **kwargs)
@@ -247,7 +249,7 @@ def clear_can_buffers(panda):
# clear tx buffers
for i in range(4):
panda.can_clear(i)
# clear rx buffers
panda.can_clear(0xFFFF)
r = [1]
@@ -257,4 +259,4 @@ def clear_can_buffers(panda):
time.sleep(0.05)
if (time.time() - st) > 10:
print("Unable to clear can buffers for panda ", panda.get_serial())
assert False
assert False
+4 -7
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Loopback test between two black pandas (+ harness and power)
# Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test.
# To be sure, the test should be run with both harness orientations
from __future__ import print_function
import os
import sys
import time
@@ -33,11 +33,8 @@ def run_test(sleep_duration):
pandas[0] = Panda(pandas[0])
pandas[1] = Panda(pandas[1])
# find out the hardware types
type0 = pandas[0].get_type()
type1 = pandas[1].get_type()
if type0 != "\x03" or type1 != "\x03":
# find out the hardware types
if not pandas[0].is_black() or not pandas[1].is_black():
print("Connect two black pandas to run this test!")
assert False
+12 -15
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Loopback test between black panda (+ harness and power) and white/grey panda
# Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test.
# To be sure, the test should be run with both harness orientations
from __future__ import print_function
import os
import sys
import time
@@ -40,17 +40,14 @@ def run_test(sleep_duration):
pandas[0] = Panda(pandas[0])
pandas[1] = Panda(pandas[1])
# find out which one is black
type0 = pandas[0].get_type()
type1 = pandas[1].get_type()
black_panda = None
other_panda = None
if type0 == "\x03" and type1 != "\x03":
# find out which one is black
if pandas[0].is_black() and not pandas[1].is_black():
black_panda = pandas[0]
other_panda = pandas[1]
elif type0 != "\x03" and type1 == "\x03":
elif not pandas[0].is_black() and pandas[1].is_black():
black_panda = pandas[1]
other_panda = pandas[0]
else:
@@ -71,13 +68,13 @@ def run_test(sleep_duration):
test_buses(black_panda, other_panda, False, [(0, False, [0]), (1, False, [1]), (2, False, [2]), (0, True, [0, 1])], sleep_duration)
counter += 1
print("Number of cycles:", counter, "Non-zero bus errors:", nonzero_bus_errors, "Zero bus errors:", zero_bus_errors, "Content errors:", content_errors)
# Toggle relay
black_panda.set_safety_mode(Panda.SAFETY_NOOUTPUT)
time.sleep(1)
black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
time.sleep(1)
def test_buses(black_panda, other_panda, direction, test_array, sleep_duration):
global nonzero_bus_errors, zero_bus_errors, content_errors
@@ -91,7 +88,7 @@ def test_buses(black_panda, other_panda, direction, test_array, sleep_duration):
black_panda.send_heartbeat()
other_panda.send_heartbeat()
print("\ntest can: ", send_bus, " OBD: ", obd)
# set OBD on black panda
black_panda.set_gmlan(True if obd else None)
@@ -105,8 +102,8 @@ def test_buses(black_panda, other_panda, direction, test_array, sleep_duration):
if direction:
other_panda.can_clear(recv_bus)
else:
black_panda.can_clear(recv_bus)
black_panda.can_clear(recv_bus)
black_panda.can_recv()
other_panda.can_recv()
@@ -138,7 +135,7 @@ def test_buses(black_panda, other_panda, direction, test_array, sleep_duration):
print(" No loop")
if not os.getenv("NOASSERT"):
assert False
# test loop buses
recv_buses.sort()
loop_buses.sort()
+11 -14
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Loopback test between black panda (+ harness and power) and white/grey panda
# Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test.
# To be sure, the test should be run with both harness orientations
from __future__ import print_function
import os
import sys
import time
@@ -40,17 +40,14 @@ def run_test(sleep_duration):
pandas[0] = Panda(pandas[0])
pandas[1] = Panda(pandas[1])
# find out which one is black
type0 = pandas[0].get_type()
type1 = pandas[1].get_type()
black_panda = None
other_panda = None
if type0 == "\x03" and type1 != "\x03":
# find out which one is black
if pandas[0].is_black() and not pandas[1].is_black():
black_panda = pandas[0]
other_panda = pandas[1]
elif type0 != "\x03" and type1 == "\x03":
elif not pandas[0].is_black() and pandas[1].is_black():
black_panda = pandas[1]
other_panda = pandas[0]
else:
@@ -78,11 +75,11 @@ def run_test(sleep_duration):
if (time.time() - temp_start_time) > 3600*6:
# Toggle relay
black_panda.set_safety_mode(Panda.SAFETY_NOOUTPUT)
time.sleep(1)
black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
time.sleep(1)
temp_start_time = time.time()
black_panda.set_safety_mode(Panda.SAFETY_NOOUTPUT)
time.sleep(1)
black_panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
time.sleep(1)
temp_start_time = time.time()
def test_buses(black_panda, other_panda, direction, test_array, sleep_duration):
@@ -111,7 +108,7 @@ def test_buses(black_panda, other_panda, direction, test_array, sleep_duration):
if direction:
other_panda.can_clear(recv_bus)
else:
black_panda.can_clear(recv_bus)
black_panda.can_clear(recv_bus)
black_panda.can_recv()
other_panda.can_recv()
+2 -2
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Relay test with loopback between black panda (+ harness and power) and white/grey panda
# Tests the relay switching multiple times / second by looking at the buses on which loop occurs.
from __future__ import print_function
import os
import sys
import time
+16 -2
View File
@@ -1,6 +1,19 @@
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y gcc-arm-none-eabi libnewlib-arm-none-eabi python python-pip gcc g++ git autoconf gperf bison flex automake texinfo wget help2man gawk libtool libtool-bin ncurses-dev unzip unrar-free libexpat-dev sed bzip2
RUN apt-get update && apt-get install -y gcc-arm-none-eabi libnewlib-arm-none-eabi python python-pip gcc g++ git autoconf gperf bison flex automake texinfo wget help2man gawk libtool libtool-bin ncurses-dev unzip unrar-free libexpat-dev sed bzip2 locales curl zlib1g-dev libffi-dev libssl-dev
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
RUN pyenv install 2.7.12
RUN pyenv install 3.7.3
RUN pyenv global 3.7.3
RUN pyenv rehash
RUN pip install pycrypto==2.6.1
@@ -10,7 +23,8 @@ WORKDIR /panda/boardesp
RUN git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
WORKDIR /panda/boardesp/esp-open-sdk
RUN git checkout 03f5e898a059451ec5f3de30e7feff30455f7ce
RUN CT_ALLOW_BUILD_AS_ROOT_SURE=1 make STANDALONE=y
COPY ./boardesp/python2_make.py /panda/boardesp/esp-open-sdk
RUN python2 python2_make.py "CT_ALLOW_BUILD_AS_ROOT_SURE=1 make STANDALONE=y"
COPY . /panda
+4 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import os
import sys
import time
@@ -15,7 +15,7 @@ def sec_since_boot():
def can_printer():
p = Panda()
p.set_safety_mode(0x1337)
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
start = sec_since_boot()
lp = sec_since_boot()
@@ -30,7 +30,7 @@ def can_printer():
if sec_since_boot() - lp > 0.1:
dd = chr(27) + "[2J"
dd += "%5.2f\n" % (sec_since_boot() - start)
for k,v in sorted(zip(msgs.keys(), map(lambda x: binascii.hexlify(x[-1]), msgs.values()))):
for k,v in sorted(zip(list(msgs.keys()), [binascii.hexlify(x[-1]) for x in list(msgs.values())])):
dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k,k),len(msgs[k]), v)
print(dd)
lp = sec_since_boot()
+13 -13
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import os
import sys
import time
@@ -19,9 +19,9 @@ if __name__ == "__main__":
serials = Panda.list()
if os.getenv("SERIAL"):
serials = filter(lambda x: x==os.getenv("SERIAL"), serials)
serials = [x for x in serials if x==os.getenv("SERIAL")]
pandas = list(map(lambda x: Panda(x, claim=claim), serials))
pandas = list([Panda(x, claim=claim) for x in serials])
if not len(pandas):
sys.exit("no pandas found")
@@ -33,16 +33,16 @@ if __name__ == "__main__":
while True:
for i, panda in enumerate(pandas):
while True:
ret = panda.serial_read(port_number)
if len(ret) > 0:
sys.stdout.write(setcolor[i] + str(ret) + unsetcolor)
sys.stdout.flush()
else:
break
ret = panda.serial_read(port_number)
if len(ret) > 0:
sys.stdout.write(setcolor[i] + ret.decode('ascii') + unsetcolor)
sys.stdout.flush()
else:
break
if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
ln = sys.stdin.readline()
if claim:
panda.serial_write(port_number, ln)
ln = sys.stdin.readline()
if claim:
panda.serial_write(port_number, ln)
time.sleep(0.01)
except:
print("panda disconnected!")
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from panda import Panda
Panda().set_esp_power(False)
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""Used to Reverse/Test ELM protocol auto detect and OBD message response without a car."""
from __future__ import print_function
import sys
import os
import struct
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import socket
import threading
import select
+4 -4
View File
@@ -1,4 +1,4 @@
from __future__ import print_function
import os
import sys
import time
@@ -8,7 +8,7 @@ import pytest
import struct
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
import elm_car_simulator
from . import elm_car_simulator
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", ".."))
from panda import Panda
@@ -301,7 +301,7 @@ def test_elm_panda_safety_mode_KWPFast():
p_car.kline_drain()
p_elm = Panda("WIFI")
p_elm.set_safety_mode(0xE327);
p_elm.set_safety_mode(Panda.SAFETY_ELM327);
def get_checksum(dat):
result = 0
@@ -625,7 +625,7 @@ def test_elm_panda_safety_mode_ISO15765():
p_car.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
p_elm = Panda("WIFI")
p_elm.set_safety_mode(0xE327);
p_elm.set_safety_mode(Panda.SAFETY_ELM327);
#sim = elm_car_simulator.ELMCarSimulator(serial, lin=False)
#sim.start()
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from panda import Panda
if __name__ == "__main__":
+3 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import time
from panda import Panda
@@ -12,6 +12,6 @@ while 1:
if len(ret) > 0:
add = ret[0][0]
if last_add is not None and add != last_add+1:
print "MISS %d %d" % (last_add, add)
print("MISS %d %d" % (last_add, add))
last_add = add
print ret
print(ret)
+4 -4
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import numpy as np
import visa
import matplotlib.pyplot as plt
resources = visa.ResourceManager()
print resources.list_resources()
print(resources.list_resources())
scope = resources.open_resource('USB0::0x1AB1::0x04CE::DS1ZA184652242::INSTR', timeout=2000, chunk_size=1024000)
print(scope.query('*IDN?').strip())
@@ -17,7 +17,7 @@ scope.write(":WAV:POIN:MODE RAW")
scope.write(":WAV:DATA? CHAN1")[10:]
rawdata = scope.read_raw()
data = np.frombuffer(rawdata, 'B')
print data.shape
print(data.shape)
s1 = data[0:650]
s2 = data[650:]
@@ -31,5 +31,5 @@ plt.plot(s2)
plt.show()
#data = (data - 130.0 - voltoffset/voltscale*25) / 25 * voltscale
print data
print(data)
+2 -2
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import time
from panda import Panda
@@ -28,6 +28,6 @@ while 1:
#p1.set_gmlan(bus=2)
#p1.can_send(iden, dat, bus=3)
time.sleep(0.01)
print p2.can_recv()
print(p2.can_recv())
#exit(0)
+3 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import time
from panda import Panda
@@ -9,9 +9,9 @@ p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
p.set_gmlan(bus=2)
time.sleep(0.1)
while len(p.can_recv()) > 0:
print "clearing"
print("clearing")
time.sleep(0.1)
print "cleared"
print("cleared")
p.set_gmlan(bus=None)
iden = 18000
+169
View File
@@ -0,0 +1,169 @@
#!/usr/bin/env python3
import os
import sys
import time
import random
import threading
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
from panda import Panda, PandaSerial
INIT_GPS_BAUD = 9600
GPS_BAUD = 460800
def connect():
pandas = Panda.list()
print(pandas)
# make sure two pandas are connected
if len(pandas) != 2:
print("Connect white and grey/black panda to run this test!")
assert False
# connect
pandas[0] = Panda(pandas[0])
pandas[1] = Panda(pandas[1])
white_panda = None
gps_panda = None
# find out which one is white (for spamming the CAN buses)
if pandas[0].is_white() and not pandas[1].is_white():
white_panda = pandas[0]
gps_panda = pandas[1]
elif not pandas[0].is_white() and pandas[1].is_white():
white_panda = pandas[1]
gps_panda = pandas[0]
else:
print("Connect white and grey/black panda to run this test!")
assert False
return white_panda, gps_panda
def spam_buses_thread(panda):
try:
panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
while True:
at = random.randint(1, 2000)
st = (b"test"+os.urandom(10))[0:8]
bus = random.randint(0, 2)
panda.can_send(at, st, bus)
except Exception as e:
print(e)
def read_can_thread(panda):
try:
while True:
panda.can_recv()
except Exception as e:
print(e)
def init_gps(panda):
def add_nmea_checksum(msg):
d = msg[1:]
cs = 0
for i in d:
cs ^= ord(i)
return msg + "*%02X" % cs
ser = PandaSerial(panda, 1, INIT_GPS_BAUD)
# Power cycle the gps by toggling reset
print("Resetting GPS")
panda.set_esp_power(0)
time.sleep(0.5)
panda.set_esp_power(1)
time.sleep(0.5)
# Upping baud rate
print("Upping GPS baud rate")
msg = add_nmea_checksum("$PUBX,41,1,0007,0003,%d,0" % GPS_BAUD)+"\r\n"
ser.write(msg)
time.sleep(1) # needs a wait for it to actually send
# Reconnecting with the correct baud
ser = PandaSerial(panda, 1, GPS_BAUD)
# Sending all config messages boardd sends
print("Sending config")
ser.write("\xB5\x62\x06\x00\x14\x00\x03\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x1E\x7F")
ser.write("\xB5\x62\x06\x3E\x00\x00\x44\xD2")
ser.write("\xB5\x62\x06\x00\x14\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x35")
ser.write("\xB5\x62\x06\x00\x14\x00\x01\x00\x00\x00\xC0\x08\x00\x00\x00\x08\x07\x00\x01\x00\x01\x00\x00\x00\x00\x00\xF4\x80")
ser.write("\xB5\x62\x06\x00\x14\x00\x04\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1D\x85")
ser.write("\xB5\x62\x06\x00\x00\x00\x06\x18")
ser.write("\xB5\x62\x06\x00\x01\x00\x01\x08\x22")
ser.write("\xB5\x62\x06\x00\x01\x00\x02\x09\x23")
ser.write("\xB5\x62\x06\x00\x01\x00\x03\x0A\x24")
ser.write("\xB5\x62\x06\x08\x06\x00\x64\x00\x01\x00\x00\x00\x79\x10")
ser.write("\xB5\x62\x06\x24\x24\x00\x05\x00\x04\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5A\x63")
ser.write("\xB5\x62\x06\x1E\x14\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3C\x37")
ser.write("\xB5\x62\x06\x24\x00\x00\x2A\x84")
ser.write("\xB5\x62\x06\x23\x00\x00\x29\x81")
ser.write("\xB5\x62\x06\x1E\x00\x00\x24\x72")
ser.write("\xB5\x62\x06\x01\x03\x00\x01\x07\x01\x13\x51")
ser.write("\xB5\x62\x06\x01\x03\x00\x02\x15\x01\x22\x70")
ser.write("\xB5\x62\x06\x01\x03\x00\x02\x13\x01\x20\x6C")
print("Initialized GPS")
received_messages = 0
received_bytes = 0
send_something = False
def gps_read_thread(panda):
global received_messages, received_bytes, send_something
ser = PandaSerial(panda, 1, GPS_BAUD)
while True:
ret = ser.read(1024)
time.sleep(0.001)
l = len(ret)
if l > 0:
received_messages+=1
received_bytes+=l
if send_something:
ser.write("test")
send_something = False
CHECK_PERIOD = 5
MIN_BYTES = 10000
MAX_BYTES = 50000
min_failures = 0
max_failures = 0
if __name__ == "__main__":
white_panda, gps_panda = connect()
# Start spamming the CAN buses with the white panda. Also read the messages to add load on the GPS panda
threading.Thread(target=spam_buses_thread, args=(white_panda,)).start()
threading.Thread(target=read_can_thread, args=(gps_panda,)).start()
# Start GPS checking
init_gps(gps_panda)
read_thread = threading.Thread(target=gps_read_thread, args=(gps_panda,))
read_thread.start()
while True:
time.sleep(CHECK_PERIOD)
if(received_bytes < MIN_BYTES):
print("Panda is not sending out enough data! Got " + str(received_messages) + " (" + str(received_bytes) + "B) in the last " + str(CHECK_PERIOD) + " seconds")
send_something = True
min_failures+=1
elif(received_bytes > MAX_BYTES):
print("Panda is not sending out too much data! Got " + str(received_messages) + " (" + str(received_bytes) + "B) in the last " + str(CHECK_PERIOD) + " seconds")
print("Probably not on the right baud rate, got reset somehow? Resetting...")
max_failures+=1
init_gps(gps_panda)
else:
print("Got " + str(received_messages) + " (" + str(received_bytes) + "B) messages in the last " + str(CHECK_PERIOD) + " seconds.")
if(min_failures > 0):
print("Total min failures: ", min_failures)
if(max_failures > 0):
print("Total max failures: ", max_failures)
received_messages = 0
received_bytes = 0
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import time
from panda import Panda
if __name__ == "__main__":
panda_serials = Panda.list()
pandas = []
+14 -2
View File
@@ -1,6 +1,18 @@
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y make python python-pip
RUN apt-get update && apt-get install -y make python python-pip locales curl git zlib1g-dev libffi-dev bzip2 libssl-dev
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
RUN pyenv install 3.7.3
RUN pyenv global 3.7.3
RUN pyenv rehash
COPY tests/safety/requirements.txt /panda/tests/safety/requirements.txt
RUN pip install -r /panda/tests/safety/requirements.txt
COPY . /panda
+3 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import subprocess
import sys
@@ -18,11 +18,11 @@ if __name__ == "__main__":
try:
cmd = "cd ../../; grep -R -i -w " + suffix_cmd + " '" + line + "'"
res = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
print res
print(res)
found_bad_language = True
except subprocess.CalledProcessError as e:
pass
if found_bad_language:
sys.exit("Failed: found bad language")
else:
print "Success"
print("Success")
+7 -7
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import time
import sys
@@ -18,20 +18,20 @@ if __name__ == "__main__":
ser = PandaSerial(panda, 1, 9600)
# power cycle by toggling reset
print "resetting"
print("resetting")
panda.set_esp_power(0)
time.sleep(0.5)
panda.set_esp_power(1)
time.sleep(0.5)
print "done"
print ser.read(1024)
print("done")
print(ser.read(1024))
# upping baud rate
baudrate = 460800
print "upping baud rate"
print("upping baud rate")
msg = add_nmea_checksum("$PUBX,41,1,0007,0003,%d,0" % baudrate)+"\r\n"
print msg
print(msg)
ser.write(msg)
time.sleep(0.1) # needs a wait for it to actually send
@@ -41,7 +41,7 @@ if __name__ == "__main__":
while True:
ret = ser.read(1024)
if len(ret) > 0:
sys.stdout.write(ret)
sys.stdout.write(ret.decode('ascii', 'ignore'))
sys.stdout.flush()
#print str(ret).encode("hex")
+4 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import os
import sys
import time
@@ -29,14 +29,14 @@ def run_test(sleep_duration):
run_test_w_pandas(pandas, sleep_duration)
def run_test_w_pandas(pandas, sleep_duration):
h = list(map(lambda x: Panda(x), pandas))
h = list([Panda(x) for x in pandas])
print("H", h)
for hh in h:
hh.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
# test both directions
for ho in permutations(range(len(h)), r=2):
for ho in permutations(list(range(len(h))), r=2):
print("***************** TESTING", ho)
panda0, panda1 = h[ho[0]], h[ho[1]]
+143
View File
@@ -0,0 +1,143 @@
1.1
1.2
1.3 X (Cppcheck)
2.1 X (Cppcheck)
2.2 X (Cppcheck)
2.3
2.4 X (Cppcheck)
2.5
2.6 X (Cppcheck)
2.7
3.1 X (Addon)
3.2
4.1 X (Addon)
4.2
5.1 X (Addon)
5.2 X (Addon)
5.3 X (Addon)
5.4 X (Addon)
5.5 X (Addon)
5.6
5.7
5.8
5.9
6.1
6.2
7.1 X (Addon)
7.2
7.3 X (Addon)
7.4
8.1
8.2
8.3 X (Cppcheck)
8.4
8.5
8.6
8.7
8.8
8.9
8.10
8.11 X (Addon)
8.12 X (Addon)
8.13
8.14 X (Addon)
9.1
9.2
9.3
9.4
9.5 X (Addon)
10.1 X (Addon)
10.2
10.3
10.4 X (Addon)
10.5
10.6 X (Addon)
10.7
10.8 X (Addon)
11.1
11.2
11.3 X (Addon)
11.4 X (Addon)
11.5 X (Addon)
11.6 X (Addon)
11.7 X (Addon)
11.8 X (Addon)
11.9 X (Addon)
12.1 X (Addon)
12.2 X (Addon)
12.3 X (Addon)
12.4 X (Addon)
13.1 X (Addon)
13.2 X (Cppcheck)
13.3 X (Addon)
13.4 X (Addon)
13.5 X (Addon)
13.6 X (Addon)
14.1 X (Addon)
14.2 X (Addon)
14.3 X (Cppcheck)
14.4 X (Addon)
15.1 X (Addon)
15.2 X (Addon)
15.3 X (Addon)
15.4
15.5 X (Addon)
15.6 X (Addon)
15.7 X (Addon)
16.1
16.2 X (Addon)
16.3 X (Addon)
16.4 X (Addon)
16.5 X (Addon)
16.6 X (Addon)
16.7 X (Addon)
17.1 X (Addon)
17.2 X (Addon)
17.3
17.4
17.5 X (Cppcheck)
17.6 X (Addon)
17.7 X (Addon)
17.8 X (Addon)
18.1 X (Cppcheck)
18.2 X (Cppcheck)
18.3 X (Cppcheck)
18.4 X (Addon)
18.5 X (Addon)
18.6 X (Cppcheck)
18.7 X (Addon)
18.8 X (Addon)
19.1
19.2 X (Addon)
20.1 X (Addon)
20.2 X (Addon)
20.3 X (Addon)
20.4 X (Addon)
20.5 X (Addon)
20.6 X (Cppcheck)
20.7 X (Addon)
20.8
20.9
20.10 X (Addon)
20.11
20.12
20.13 X (Addon)
20.14 X (Addon)
21.1
21.2
21.3 X (Addon)
21.4 X (Addon)
21.5 X (Addon)
21.6 X (Addon)
21.7 X (Addon)
21.8 X (Addon)
21.9 X (Addon)
21.10 X (Addon)
21.11 X (Addon)
21.12
22.1 X (Cppcheck)
22.2 X (Cppcheck)
22.3
22.4 X (Cppcheck)
22.5
22.6 X (Cppcheck)
-2
View File
@@ -1,7 +1,5 @@
# Advisory: union types can be used
misra.19.2
# FIXME: add it back when fixed in cppcheck. Macro identifiers are unique but it false triggers on defines in #ifdef..#else conditions
misra.5.4
# Advisory: casting from void pointer to type pointer is ok. Done by STM libraries as well
misra.11.4
# Advisory: casting from void pointer to type pointer is ok. Done by STM libraries as well
+7 -5
View File
@@ -4,10 +4,12 @@ mkdir /tmp/misra || true
git clone https://github.com/danmar/cppcheck.git || true
cd cppcheck
git fetch
git checkout 862c4ef87b109ae86c2d5f12769b7c8d199f35c5
git checkout ff7dba91e177dfb712477faddb9e91bece7e743c
make -j4
cd ../../../
# generate coverage matrix
python tests/misra/cppcheck/addons/misra.py -generate-table > tests/misra/coverage_table
printf "\nPANDA CODE\n"
tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE -DEON \
@@ -18,8 +20,8 @@ tests/misra/cppcheck/cppcheck -DPANDA -UPEDAL -DCAN3 -DUID_BASE -DEON \
python tests/misra/cppcheck/addons/misra.py board/main.c.dump 2> /tmp/misra/misra_output.txt || true
# strip (information) lines
cppcheck_output=$( cat /tmp/misra/cppcheck_output.txt | grep -v "(information) " ) || true
misra_output=$( cat /tmp/misra/misra_output.txt | grep -v "(information) " ) || true
cppcheck_output=$( cat /tmp/misra/cppcheck_output.txt | grep -v ": information: " ) || true
misra_output=$( cat /tmp/misra/misra_output.txt | grep -v ": information: " ) || true
printf "\nPEDAL CODE\n"
@@ -31,8 +33,8 @@ tests/misra/cppcheck/cppcheck -UPANDA -DPEDAL -UCAN3 \
python tests/misra/cppcheck/addons/misra.py board/pedal/main.c.dump 2> /tmp/misra/misra_pedal_output.txt || true
# strip (information) lines
cppcheck_pedal_output=$( cat /tmp/misra/cppcheck_pedal_output.txt | grep -v "(information) " ) || true
misra_pedal_output=$( cat /tmp/misra/misra_pedal_output.txt | grep -v "(information) " ) || true
cppcheck_pedal_output=$( cat /tmp/misra/cppcheck_pedal_output.txt | grep -v ": information: " ) || true
misra_pedal_output=$( cat /tmp/misra/misra_pedal_output.txt | grep -v ": information: " ) || true
if [[ -n "$misra_output" ]] || [[ -n "$cppcheck_output" ]]
then
+7 -7
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import time
import struct
@@ -53,24 +53,24 @@ if __name__ == "__main__":
args = parser.parse_args()
p = Panda()
p.set_safety_mode(0x1337)
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
while 1:
if len(p.can_recv()) == 0:
break
if args.recover:
p.can_send(0x200, "\xce\xfa\xad\xde\x1e\x0b\xb0\x02", 0)
p.can_send(0x200, b"\xce\xfa\xad\xde\x1e\x0b\xb0\x02", 0)
exit(0)
else:
p.can_send(0x200, "\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 0)
p.can_send(0x200, b"\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 0)
if args.fn:
time.sleep(0.1)
print "flashing", args.fn
code = open(args.fn).read()
print("flashing", args.fn)
code = open(args.fn, "rb").read()
Panda.flash_static(CanHandle(p), code)
print "can flash done"
print("can flash done")
+8 -8
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from panda import Panda
from hexdump import hexdump
@@ -8,22 +8,22 @@ if __name__ == "__main__":
p = Panda()
len = p._handle.controlRead(Panda.REQUEST_IN, 0x06, 3 << 8 | 238, 0, 1)
print 'Microsoft OS String Descriptor'
print('Microsoft OS String Descriptor')
dat = p._handle.controlRead(Panda.REQUEST_IN, 0x06, 3 << 8 | 238, 0, len[0])
if DEBUG: print 'LEN: {}'.format(hex(len[0]))
if DEBUG: print('LEN: {}'.format(hex(len[0])))
hexdump("".join(map(chr, dat)))
ms_vendor_code = dat[16]
if DEBUG: print 'MS_VENDOR_CODE: {}'.format(hex(len[0]))
if DEBUG: print('MS_VENDOR_CODE: {}'.format(hex(len[0])))
print '\nMicrosoft Compatible ID Feature Descriptor'
print('\nMicrosoft Compatible ID Feature Descriptor')
len = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 4, 1)
if DEBUG: print 'LEN: {}'.format(hex(len[0]))
if DEBUG: print('LEN: {}'.format(hex(len[0])))
dat = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 4, len[0])
hexdump("".join(map(chr, dat)))
print '\nMicrosoft Extended Properties Feature Descriptor'
print('\nMicrosoft Extended Properties Feature Descriptor')
len = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 5, 1)
if DEBUG: print 'LEN: {}'.format(hex(len[0]))
if DEBUG: print('LEN: {}'.format(hex(len[0])))
dat = p._handle.controlRead(Panda.REQUEST_IN, ms_vendor_code, 0, 5, len[0])
hexdump("".join(map(chr, dat)))
+16 -3
View File
@@ -1,6 +1,19 @@
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y clang make python python-pip
COPY tests/safety/requirements.txt /panda/tests/safety/requirements.txt
RUN pip install -r /panda/tests/safety/requirements.txt
RUN apt-get update && apt-get install -y clang make python python-pip git curl locales zlib1g-dev libffi-dev bzip2 libssl-dev libbz2-dev libusb-1.0-0
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
RUN pyenv install 3.7.3
RUN pyenv global 3.7.3
RUN pyenv rehash
COPY tests/safety/requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . /panda
+3 -1
View File
@@ -1,2 +1,4 @@
cffi==1.11.4
numpy==1.14.1
numpy==1.14.5
libusb1==1.6.6
requests
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_RATE_UP = 2
MAX_RATE_DOWN = 5
@@ -31,7 +32,7 @@ class TestCadillacSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(6, 0)
cls.safety.safety_set_mode(Panda.SAFETY_CADILLAC, 0)
cls.safety.init_tests_cadillac()
def _send_msg(self, bus, addr, length):
@@ -183,8 +184,8 @@ class TestCadillacSafety(unittest.TestCase):
def test_fwd_hook(self):
# nothing allowed
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
for b in buss:
for m in msgs:
+5 -4
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import csv
import glob
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_RATE_UP = 3
MAX_RATE_DOWN = 3
@@ -35,7 +36,7 @@ class TestChryslerSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(9, 0)
cls.safety.safety_set_mode(Panda.SAFETY_CHRYSLER, 0)
cls.safety.init_tests_chrysler()
def _send_msg(self, bus, addr, length):
@@ -181,8 +182,8 @@ class TestChryslerSafety(unittest.TestCase):
self.assertEqual(0, self.safety.get_chrysler_torque_meas_min())
def test_fwd_hook(self):
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
chrysler_camera_detected = [0, 1]
for ccd in chrysler_camera_detected:
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_RATE_UP = 7
MAX_RATE_DOWN = 17
@@ -32,7 +33,7 @@ class TestGmSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(3, 0)
cls.safety.safety_set_mode(Panda.SAFETY_GM, 0)
cls.safety.init_tests_gm()
def _send_msg(self, bus, addr, length):
@@ -282,8 +283,8 @@ class TestGmSafety(unittest.TestCase):
def test_fwd_hook(self):
# nothing allowed
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
for b in buss:
for m in msgs:
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_BRAKE = 255
@@ -11,7 +12,7 @@ class TestHondaSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(1, 0)
cls.safety.safety_set_mode(Panda.SAFETY_HONDA, 0)
cls.safety.init_tests_honda()
def _send_msg(self, bus, addr, length):
@@ -254,8 +255,8 @@ class TestHondaSafety(unittest.TestCase):
self.assertTrue(self.safety.safety_tx_hook(self._button_msg(RESUME_BTN, BUTTON_MSG)))
def test_fwd_hook(self):
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
long_controls_allowed = [0, 1]
fwd_brake = [False, True]
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_BRAKE = 255
@@ -9,7 +10,7 @@ class TestHondaSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(4, 0)
cls.safety.safety_set_mode(Panda.SAFETY_HONDA_BOSCH, 0)
cls.safety.init_tests_honda()
def _send_msg(self, bus, addr, length):
@@ -21,8 +22,8 @@ class TestHondaSafety(unittest.TestCase):
return to_send
def test_fwd_hook(self):
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
is_panda_black = self.safety.get_hw_type() == 3 # black panda
bus_rdr_cam = 2 if is_panda_black else 1
bus_rdr_car = 0 if is_panda_black else 2
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_RATE_UP = 3
MAX_RATE_DOWN = 7
@@ -29,7 +30,7 @@ class TestHyundaiSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(7, 0)
cls.safety.safety_set_mode(Panda.SAFETY_HYUNDAI, 0)
cls.safety.init_tests_hyundai()
def _send_msg(self, bus, addr, length):
@@ -190,8 +191,8 @@ class TestHyundaiSafety(unittest.TestCase):
def test_fwd_hook(self):
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
hyundai_giraffe_switch_2 = [0, 1]
self.safety.set_hyundai_camera_bus(2)
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_RATE_UP = 50
MAX_RATE_DOWN = 70
@@ -29,7 +30,7 @@ class TestSubaruSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(10, 0)
cls.safety.safety_set_mode(Panda.SAFETY_SUBARU, 0)
cls.safety.init_tests_subaru()
def _send_msg(self, bus, addr, length):
@@ -174,8 +175,8 @@ class TestSubaruSafety(unittest.TestCase):
def test_fwd_hook(self):
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
blocked_msgs = [290, 356, 545, 802]
for b in buss:
for m in msgs:
+5 -4
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
MAX_RATE_UP = 10
MAX_RATE_DOWN = 25
@@ -33,7 +34,7 @@ class TestToyotaSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(2, 100)
cls.safety.safety_set_mode(Panda.SAFETY_TOYOTA, 100)
cls.safety.init_tests_toyota()
def _send_msg(self, bus, addr, length):
@@ -281,8 +282,8 @@ class TestToyotaSafety(unittest.TestCase):
def test_fwd_hook(self):
buss = range(0x0, 0x3)
msgs = range(0x1, 0x800)
buss = list(range(0x0, 0x3))
msgs = list(range(0x1, 0x800))
long_controls_allowed = [0, 1]
toyota_camera_forwarded = [0, 1]
+4 -3
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import unittest
import numpy as np
import libpandasafety_py
from panda import Panda
IPAS_OVERRIDE_THRESHOLD = 200
@@ -25,7 +26,7 @@ class TestToyotaSafety(unittest.TestCase):
@classmethod
def setUp(cls):
cls.safety = libpandasafety_py.libpandasafety
cls.safety.safety_set_mode(0x1335, 66)
cls.safety.safety_set_mode(Panda.SAFETY_TOYOTA_IPAS, 66)
cls.safety.init_tests_toyota()
def _torque_driver_msg(self, torque):
@@ -135,7 +136,7 @@ class TestToyotaSafety(unittest.TestCase):
# test angle cmd too far from actual
angle_refs = [-10, 10]
deltas = range(-2, 3)
deltas = list(range(-2, 3))
expected_results = [False, True, True, True, False]
for a in angle_refs:
+14 -2
View File
@@ -1,6 +1,18 @@
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y make clang python python-pip git libarchive-dev libusb-1.0-0
RUN apt-get update && apt-get install -y make clang python python-pip git libarchive-dev libusb-1.0-0 locales curl zlib1g-dev libffi-dev bzip2 libssl-dev libbz2-dev
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
RUN pyenv install 3.7.3
RUN pyenv global 3.7.3
RUN pyenv rehash
COPY tests/safety_replay/requirements.txt requirements.txt
RUN pip install -r requirements.txt
@@ -17,4 +29,4 @@ COPY . /openpilot/panda
WORKDIR /openpilot/panda/tests/safety_replay
RUN git clone https://github.com/commaai/openpilot-tools.git tools || true
WORKDIR tools
RUN git checkout feb724a14f0f5223c700c94317efaf46923fd48a
RUN git checkout d69c6bc85f221766305ec53956e9a1d3bf283160
+20 -36
View File
@@ -1,23 +1,7 @@
#!/usr/bin/env python3
import struct
import panda.tests.safety.libpandasafety_py as libpandasafety_py
safety_modes = {
"NOOUTPUT": 0,
"HONDA": 1,
"TOYOTA": 2,
"GM": 3,
"HONDA_BOSCH": 4,
"FORD": 5,
"CADILLAC": 6,
"HYUNDAI": 7,
"TESLA": 8,
"CHRYSLER": 9,
"SUBARU": 10,
"GM_ASCM": 0x1334,
"TOYOTA_IPAS": 0x1335,
"ALLOUTPUT": 0x1337,
"ELM327": 0xE327
}
from panda import Panda
def to_signed(d, bits):
ret = d
@@ -27,51 +11,51 @@ def to_signed(d, bits):
def is_steering_msg(mode, addr):
ret = False
if mode == safety_modes["HONDA"] or mode == safety_modes["HONDA_BOSCH"]:
if mode == Panda.SAFETY_HONDA or mode == Panda.SAFETY_HONDA_BOSCH:
ret = (addr == 0xE4) or (addr == 0x194) or (addr == 0x33D)
elif mode == safety_modes["TOYOTA"]:
elif mode == Panda.SAFETY_TOYOTA:
ret = addr == 0x2E4
elif mode == safety_modes["GM"]:
elif mode == Panda.SAFETY_GM:
ret = addr == 384
elif mode == safety_modes["HYUNDAI"]:
elif mode == Panda.SAFETY_HYUNDAI:
ret = addr == 832
elif mode == safety_modes["CHRYSLER"]:
elif mode == Panda.SAFETY_CHRYSLER:
ret = addr == 0x292
elif mode == safety_modes["SUBARU"]:
elif mode == Panda.SAFETY_SUBARU:
ret = addr == 0x122
return ret
def get_steer_torque(mode, to_send):
ret = 0
if mode == safety_modes["HONDA"] or mode == safety_modes["HONDA_BOSCH"]:
if mode == Panda.SAFETY_HONDA or mode == Panda.SAFETY_HONDA_BOSCH:
ret = to_send.RDLR & 0xFFFF0000
elif mode == safety_modes["TOYOTA"]:
elif mode == Panda.SAFETY_TOYOTA:
ret = (to_send.RDLR & 0xFF00) | ((to_send.RDLR >> 16) & 0xFF)
ret = to_signed(ret, 16)
elif mode == safety_modes["GM"]:
elif mode == Panda.SAFETY_GM:
ret = ((to_send.RDLR & 0x7) << 8) + ((to_send.RDLR & 0xFF00) >> 8)
ret = to_signed(ret, 11)
elif mode == safety_modes["HYUNDAI"]:
elif mode == Panda.SAFETY_HYUNDAI:
ret = ((to_send.RDLR >> 16) & 0x7ff) - 1024
elif mode == safety_modes["CHRYSLER"]:
elif mode == Panda.SAFETY_CHRYSLER:
ret = ((to_send.RDLR & 0x7) << 8) + ((to_send.RDLR & 0xFF00) >> 8) - 1024
elif mode == safety_modes["SUBARU"]:
elif mode == Panda.SAFETY_SUBARU:
ret = ((to_send.RDLR >> 16) & 0x1FFF)
ret = to_signed(ret, 13)
return ret
def set_desired_torque_last(safety, mode, torque):
if mode == safety_modes["HONDA"] or mode == safety_modes["HONDA_BOSCH"]:
if mode == Panda.SAFETY_HONDA or mode == Panda.SAFETY_HONDA_BOSCH:
pass # honda safety mode doesn't enforce a rate on steering msgs
elif mode == safety_modes["TOYOTA"]:
elif mode == Panda.SAFETY_TOYOTA:
safety.set_toyota_desired_torque_last(torque)
elif mode == safety_modes["GM"]:
elif mode == Panda.SAFETY_GM:
safety.set_gm_desired_torque_last(torque)
elif mode == safety_modes["HYUNDAI"]:
elif mode == Panda.SAFETY_HYUNDAI:
safety.set_hyundai_desired_torque_last(torque)
elif mode == safety_modes["CHRYSLER"]:
elif mode == Panda.SAFETY_CHRYSLER:
safety.set_chrysler_desired_torque_last(torque)
elif mode == safety_modes["SUBARU"]:
elif mode == Panda.SAFETY_SUBARU:
safety.set_subaru_desired_torque_last(torque)
def package_can_msg(msg):
+12 -14
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import os
import sys
from panda import Panda
import panda.tests.safety.libpandasafety_py as libpandasafety_py
from panda.tests.safety_replay.helpers import is_steering_msg, get_steer_torque, \
set_desired_torque_last, package_can_msg, \
init_segment, safety_modes
init_segment
from tools.lib.logreader import LogReader
# replay a drive to check for safety violations
@@ -25,7 +26,7 @@ def replay_drive(lr, safety_mode, param):
for msg in lr:
if start_t is None:
start_t = msg.logMonoTime
safety.set_timer(((msg.logMonoTime / 1000)) % 0xFFFFFFFF)
safety.set_timer(((msg.logMonoTime // 1000)) % 0xFFFFFFFF)
if msg.which() == 'sendcan':
for canmsg in msg.sendcan:
@@ -37,7 +38,7 @@ def replay_drive(lr, safety_mode, param):
blocked_addrs.add(canmsg.address)
if "DEBUG" in os.environ:
print "blocked %d at %f" % (canmsg.address, (msg.logMonoTime - start_t)/(1e9))
print("blocked %d at %f" % (canmsg.address, (msg.logMonoTime - start_t)/(1e9)))
tx_controls += safety.get_controls_allowed()
tx_tot += 1
elif msg.which() == 'can':
@@ -48,23 +49,20 @@ def replay_drive(lr, safety_mode, param):
to_push = package_can_msg(canmsg)
safety.safety_rx_hook(to_push)
print "total openpilot msgs:", tx_tot
print "total msgs with controls allowed:", tx_controls
print "blocked msgs:", tx_blocked
print "blocked with controls allowed:", tx_controls_blocked
print "blocked addrs:", blocked_addrs
print("total openpilot msgs:", tx_tot)
print("total msgs with controls allowed:", tx_controls)
print("blocked msgs:", tx_blocked)
print("blocked with controls allowed:", tx_controls_blocked)
print("blocked addrs:", blocked_addrs)
return tx_controls_blocked == 0
if __name__ == "__main__":
if sys.argv[2] in safety_modes:
mode = safety_modes[sys.argv[2]]
else:
mode = int(sys.argv[2])
mode = int(sys.argv[2])
param = 0 if len(sys.argv) < 4 else int(sys.argv[3])
lr = LogReader(sys.argv[1])
print "replaying drive %s with safety mode %d and param %d" % (sys.argv[1], mode, param)
print("replaying drive %s with safety mode %d and param %d" % (sys.argv[1], mode, param))
replay_drive(lr, mode, param)
+13 -14
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import os
import requests
from helpers import safety_modes
from panda import Panda
from replay_drive import replay_drive
from tools.lib.logreader import LogReader
@@ -11,31 +11,30 @@ BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/"
# (route, safety mode, param)
logs = [
("b0c9d2329ad1606b|2019-05-30--20-23-57.bz2", "HONDA", 0), # HONDA.CIVIC
("38bfd238edecbcd7|2019-06-07--10-15-25.bz2", "TOYOTA", 66), # TOYOTA.PRIUS
("f89c604cf653e2bf|2018-09-29--13-46-50.bz2", "GM", 0), # GM.VOLT
("0375fdf7b1ce594d|2019-05-21--20-10-33.bz2", "HONDA_BOSCH", 1), # HONDA.ACCORD
("02ec6bea180a4d36|2019-04-17--11-21-35.bz2", "HYUNDAI", 0), # HYUNDAI.SANTA_FE
("03efb1fda29e30fe|2019-02-21--18-03-45.bz2", "CHRYSLER", 0), # CHRYSLER.PACIFICA_2018_HYBRID
("791340bc01ed993d|2019-04-08--10-26-00.bz2", "SUBARU", 0), # SUBARU.IMPREZA
("b0c9d2329ad1606b|2019-05-30--20-23-57.bz2", Panda.SAFETY_HONDA, 0), # HONDA.CIVIC
("38bfd238edecbcd7|2019-06-07--10-15-25.bz2", Panda.SAFETY_TOYOTA, 66), # TOYOTA.PRIUS
("f89c604cf653e2bf|2018-09-29--13-46-50.bz2", Panda.SAFETY_GM, 0), # GM.VOLT
("0375fdf7b1ce594d|2019-05-21--20-10-33.bz2", Panda.SAFETY_HONDA_BOSCH, 1), # HONDA.ACCORD
("02ec6bea180a4d36|2019-04-17--11-21-35.bz2", Panda.SAFETY_HYUNDAI, 0), # HYUNDAI.SANTA_FE
("03efb1fda29e30fe|2019-02-21--18-03-45.bz2", Panda.SAFETY_CHRYSLER, 0), # CHRYSLER.PACIFICA_2018_HYBRID
("791340bc01ed993d|2019-04-08--10-26-00.bz2", Panda.SAFETY_SUBARU, 0), # SUBARU.IMPREZA
]
if __name__ == "__main__":
for route, _, _ in logs:
if not os.path.isfile(route):
with open(route, "w") as f:
with open(route, "wb") as f:
f.write(requests.get(BASE_URL + route).content)
failed = []
for route, mode, param in logs:
lr = LogReader(route)
m = safety_modes.get(mode, mode)
print "\nreplaying %s with safety mode %d and param %s" % (route, m, param)
if not replay_drive(lr, m, int(param)):
print("\nreplaying %s with safety mode %d and param %s" % (route, mode, param))
if not replay_drive(lr, mode, int(param)):
failed.append(route)
for f in failed:
print "\n**** failed on %s ****" % f
print("\n**** failed on %s ****" % f)
assert len(failed) == 0, "\nfailed on %d logs" % len(failed)
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
import os
import sys
import time
import random
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
from panda import Panda
def get_test_string():
return b"test"+os.urandom(10)
if __name__ == "__main__":
p = Panda()
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
print("Spamming all buses...")
while True:
at = random.randint(1, 2000)
st = get_test_string()[0:8]
bus = random.randint(0, 2)
p.can_send(at, st, bus)
#print("Sent message on bus: ", bus)
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
import struct
+4 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import os
import sys
import struct
@@ -34,7 +34,7 @@ if __name__ == "__main__":
p_in.can_recv()
BATCH_SIZE = 16
for a in tqdm(range(0, 10000, BATCH_SIZE)):
for a in tqdm(list(range(0, 10000, BATCH_SIZE))):
for b in range(0, BATCH_SIZE):
msg = b"\xaa"*4 + struct.pack("I", a+b)
if a%1 == 0:
@@ -61,4 +61,4 @@ if __name__ == "__main__":
if len(set_out - set_in):
print("MISSING %d" % len(set_out - set_in))
if len(set_out - set_in) < 256:
print(map(hex, sorted(list(set_out - set_in))))
print(list(map(hex, sorted(list(set_out - set_in)))))
+4 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import os
import sys
import time
@@ -29,14 +29,14 @@ def run_test(sleep_duration):
run_test_w_pandas(pandas, sleep_duration)
def run_test_w_pandas(pandas, sleep_duration):
h = list(map(lambda x: Panda(x), pandas))
h = list([Panda(x) for x in pandas])
print("H", h)
for hh in h:
hh.set_controls_allowed(True)
# test both directions
for ho in permutations(range(len(h)), r=2):
for ho in permutations(list(range(len(h))), r=2):
print("***************** TESTING", ho)
panda0, panda1 = h[ho[0]], h[ho[1]]