Skip to content

Commit

Permalink
Squashed 'panda/' changes from 9881e61..30c7ca8
Browse files Browse the repository at this point in the history
30c7ca8 bump version to 1.5.3
9403dbe Need to fix wifi test before re-enabling.
0812362 GPS UART fix until boardd is refactored (commaai#294)
ffbdb87 python2 -> 3 fixes to pedal flasher (commaai#292)
78b75ef Added build type to release version strings
736c2cb Fixed sending of bytes over PandaSerial
0894b28 Fixed USB power mode on black (commaai#291)
4b3358c patch to be able to switch from EON to PC with a Panda that has EON b… (commaai#290)
a95c44a Made setting of NOOUTPUT on no heartbeat more efficient (commaai#287)
9486836 UART instability fix with high interrupt load (commaai#283)
9a9e9d4 Fix usb_power_mode missing initialization (commaai#289)
af0960a DFU fix (commaai#288)
70219d7 match safety enum in cereal (commaai#285)
a338d39 Fix build for jenkins test
78ef4a6 Stop charge (commaai#284)
5266a40 Fix typo (commaai#286)
f4787ec Revert "turn on CDP when ignition switches on (commaai#281)"
d37daee Revert "NONE and CLIENT should be the same thing in white/grey pandas"
e97b283 NONE and CLIENT should be the same thing in white/grey pandas
8c1df55 turn on CDP when ignition switches on (commaai#281)
847a35d Fix bullet points
fac0277 Misra update (commaai#280)
5a04df6 Added description of regression tests to README
c4aabae Fixed some python3 bugs in the test scripts and PandaSerial
9af0cb3 Bump version
c4ac3d6 Disable GPS load switching on black pandas
078ee58 This is the correct table, actually
578b95e Misra table of coverage added
d383a26 bump panda
b98ca01 fix sdk build in python3 env (commaai#279)
63d3dc7 Set python3 env before runnign get_sdk, so we know if it fails
e951d79 legacy code we don't control can remain python2
11b7151 Merge pull request commaai#276 from commaai/python3
9893a84 Merge pull request commaai#277 from zorrobyte/patch-1
d326869 Revert "revert back esptool to python2 and force to build esptools with python2"
875e760 revert back esptool to python2 and force to build esptools with python2
9c40e62 needed to install python3
ed2ac87 Also moved safety tests to python3
6842b2d move esptool sdk installation before python3 env is set. Kind of a cheat
b5a2cab this hopefully fixes build test
6280509 Fixes safety replay
2c220b6 this fixes language regr test
fdbe789 use python 3 in Docker container
ee1ae4f Better hash print
0de9ef7 Revert "Final 2to3 on the whole repo"
c92fd3b Final 2to3 on the whole repo
5f2bc44 better
b2a30fd make works!
b74005d fix sign.py
fe72770 read file as byte and no tab before sleep
32a344ef6 Update README.md
2dc3409 2to3 applied
ffa68ef undo unnecessary brackets for print
dbc2480 Fix all the prints with 2to3, some need to be undo
5a7aeba xrange is gone
982c4c9 one more python3 env
1e2412a env python -> env python3

git-subtree-dir: panda
git-subtree-split: 30c7ca8
  • Loading branch information
Vehicle Researcher authored and jyoung8607 committed Nov 6, 2019
1 parent 2964213 commit 1f832ee
Show file tree
Hide file tree
Showing 6 changed files with 345 additions and 2 deletions.
4 changes: 4 additions & 0 deletions boardesp/python2_make.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python2
import os
import sys
os.system(sys.argv[1])
2 changes: 1 addition & 1 deletion panda/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.5.9
v1.5.9.0
5 changes: 4 additions & 1 deletion panda/python/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def read(self, l=1):
def write(self, dat):
#print "W: ", dat.encode("hex")
#print ' pigeon_send("' + ''.join(map(lambda x: "\\x%02X" % ord(x), dat)) + '");'
return self.panda.serial_write(self.port, dat)
if(isinstance(dat, bytes)):
return self.panda.serial_write(self.port, dat)
else:
return self.panda.serial_write(self.port, str.encode(dat))

def close(self):
pass
Expand Down
169 changes: 169 additions & 0 deletions tests/gps_stability_test.py
Original file line number Diff line number Diff line change
@@ -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




143 changes: 143 additions & 0 deletions tests/misra/coverage_table
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 24 additions & 0 deletions tests/spam_can.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1f832ee

Please sign in to comment.