commit
11b7151180
19
Dockerfile
19
Dockerfile
|
@ -17,11 +17,15 @@ RUN apt-get update && apt-get install -y \
|
|||
gperf \
|
||||
help2man \
|
||||
iputils-ping \
|
||||
libbz2-dev \
|
||||
libexpat-dev \
|
||||
libffi-dev \
|
||||
libssl-dev \
|
||||
libstdc++-arm-none-eabi-newlib \
|
||||
libtool \
|
||||
libtool-bin \
|
||||
libusb-1.0-0 \
|
||||
locales \
|
||||
make \
|
||||
ncurses-dev \
|
||||
network-manager \
|
||||
|
@ -38,7 +42,20 @@ RUN apt-get update && apt-get install -y \
|
|||
screen \
|
||||
vim \
|
||||
wget \
|
||||
wireless-tools
|
||||
wireless-tools \
|
||||
zlib1g-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
|
||||
|
||||
RUN pip install --upgrade pip==18.0
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import struct
|
||||
from Crypto.PublicKey import RSA
|
||||
|
@ -26,7 +26,7 @@ def to_c_uint32(x):
|
|||
nums = []
|
||||
for i in range(0x20):
|
||||
nums.append(x%(2**32))
|
||||
x /= (2**32)
|
||||
x //= (2**32)
|
||||
return "{"+'U,'.join(map(str, nums))+"U}"
|
||||
|
||||
for fn in sys.argv[1:]:
|
||||
|
@ -36,11 +36,11 @@ for fn in sys.argv[1:]:
|
|||
|
||||
cname = fn.split("/")[-1].split(".")[0] + "_rsa_key"
|
||||
|
||||
print 'RSAPublicKey '+cname+' = {.len = 0x20,'
|
||||
print ' .n0inv = %dU,' % n0inv
|
||||
print ' .n = %s,' % to_c_uint32(rsa.n)
|
||||
print ' .rr = %s,' % to_c_uint32(rr)
|
||||
print ' .exponent = %d,' % rsa.e
|
||||
print '};'
|
||||
print('RSAPublicKey '+cname+' = {.len = 0x20,')
|
||||
print(' .n0inv = %dU,' % n0inv)
|
||||
print(' .n = %s,' % to_c_uint32(rsa.n))
|
||||
print(' .rr = %s,' % to_c_uint32(rr))
|
||||
print(' .exponent = %d,' % rsa.e)
|
||||
print('};')
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import struct
|
||||
import hashlib
|
||||
from Crypto.PublicKey import RSA
|
||||
import binascii
|
||||
|
||||
rsa = RSA.importKey(open(sys.argv[3]).read())
|
||||
|
||||
with open(sys.argv[1]) as f:
|
||||
with open(sys.argv[1], "rb") as f:
|
||||
dat = f.read()
|
||||
|
||||
print "signing", len(dat), "bytes"
|
||||
print("signing", len(dat), "bytes")
|
||||
|
||||
with open(sys.argv[2], "wb") as f:
|
||||
if os.getenv("SETLEN") is not None:
|
||||
|
@ -20,10 +21,11 @@ with open(sys.argv[2], "wb") as f:
|
|||
else:
|
||||
x = dat
|
||||
dd = hashlib.sha1(dat).digest()
|
||||
print "hash:",dd.encode("hex")
|
||||
dd = "\x00\x01" + "\xff"*0x69 + "\x00" + dd
|
||||
rsa_out = pow(int(dd.encode("hex"), 16), rsa.d, rsa.n)
|
||||
sig = (hex(rsa_out)[2:-1].rjust(0x100, '0')).decode("hex")
|
||||
x += sig
|
||||
|
||||
print("hash:", str(binascii.hexlify(dd), "utf-8"))
|
||||
dd = b"\x00\x01" + b"\xff"*0x69 + b"\x00" + dd
|
||||
rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n)
|
||||
sig = (hex(rsa_out)[2:].rjust(0x100, '0'))
|
||||
x += binascii.unhexlify(sig)
|
||||
f.write(x)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import binascii
|
||||
import csv
|
||||
|
@ -13,13 +13,13 @@ class Message():
|
|||
|
||||
def printBitDiff(self, other):
|
||||
"""Prints bits that transition from always zero to always 1 and vice versa."""
|
||||
for i in xrange(len(self.ones)):
|
||||
for i in range(len(self.ones)):
|
||||
zero_to_one = other.zeros[i] & self.ones[i]
|
||||
if zero_to_one:
|
||||
print 'id %s 0 -> 1 at byte %d bitmask %d' % (self.message_id, i, zero_to_one)
|
||||
print('id %s 0 -> 1 at byte %d bitmask %d' % (self.message_id, i, zero_to_one))
|
||||
one_to_zero = other.ones[i] & self.zeros[i]
|
||||
if one_to_zero:
|
||||
print 'id %s 1 -> 0 at byte %d bitmask %d' % (self.message_id, i, one_to_zero)
|
||||
print('id %s 1 -> 0 at byte %d bitmask %d' % (self.message_id, i, one_to_zero))
|
||||
|
||||
|
||||
class Info():
|
||||
|
@ -56,7 +56,7 @@ class Info():
|
|||
new_message = True
|
||||
message = self.messages[message_id]
|
||||
bytes = bytearray.fromhex(data)
|
||||
for i in xrange(len(bytes)):
|
||||
for i in range(len(bytes)):
|
||||
ones = int(bytes[i])
|
||||
message.ones[i] = ones if new_message else message.ones[i] & ones
|
||||
# Inverts the data and masks it to a byte to get the zeros as ones.
|
||||
|
@ -65,11 +65,11 @@ class Info():
|
|||
|
||||
def PrintUnique(log_file, low_range, high_range):
|
||||
# find messages with bits that are always low
|
||||
start, end = map(float, low_range.split('-'))
|
||||
start, end = list(map(float, low_range.split('-')))
|
||||
low = Info()
|
||||
low.load(log_file, start, end)
|
||||
# find messages with bits that are always high
|
||||
start, end = map(float, high_range.split('-'))
|
||||
start, end = list(map(float, high_range.split('-')))
|
||||
high = Info()
|
||||
high.load(log_file, start, end)
|
||||
# print messages that go from low to high
|
||||
|
@ -78,10 +78,10 @@ def PrintUnique(log_file, low_range, high_range):
|
|||
if message_id in low.messages:
|
||||
high.messages[message_id].printBitDiff(low.messages[message_id])
|
||||
found = True
|
||||
if not found: print 'No messages that transition from always low to always high found!'
|
||||
if not found: print('No messages that transition from always low to always high found!')
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 4:
|
||||
print 'Usage:\n%s log.csv <low-start>-<low-end> <high-start>-<high-end>' % sys.argv[0]
|
||||
print('Usage:\n%s log.csv <low-start>-<low-end> <high-start>-<high-end>' % sys.argv[0])
|
||||
sys.exit(0)
|
||||
PrintUnique(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import binascii
|
||||
import csv
|
||||
import sys
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Given an interesting CSV file of CAN messages and a list of background CAN
|
||||
# messages, print which bits in the interesting file have never appeared
|
||||
|
@ -28,15 +28,15 @@ class Message():
|
|||
|
||||
def printBitDiff(self, other):
|
||||
"""Prints bits that are set or cleared compared to other background."""
|
||||
for i in xrange(len(self.ones)):
|
||||
for i in range(len(self.ones)):
|
||||
new_ones = ((~other.ones[i]) & 0xff) & self.ones[i]
|
||||
if new_ones:
|
||||
print 'id %s new one at byte %d bitmask %d' % (
|
||||
self.message_id, i, new_ones)
|
||||
print('id %s new one at byte %d bitmask %d' % (
|
||||
self.message_id, i, new_ones))
|
||||
new_zeros = ((~other.zeros[i]) & 0xff) & self.zeros[i]
|
||||
if new_zeros:
|
||||
print 'id %s new zero at byte %d bitmask %d' % (
|
||||
self.message_id, i, new_zeros)
|
||||
print('id %s new zero at byte %d bitmask %d' % (
|
||||
self.message_id, i, new_zeros))
|
||||
|
||||
|
||||
class Info():
|
||||
|
@ -67,7 +67,7 @@ class Info():
|
|||
if data not in self.messages[message_id].data:
|
||||
message.data[data] = True
|
||||
bytes = bytearray.fromhex(data)
|
||||
for i in xrange(len(bytes)):
|
||||
for i in range(len(bytes)):
|
||||
message.ones[i] = message.ones[i] | int(bytes[i])
|
||||
# Inverts the data and masks it to a byte to get the zeros as ones.
|
||||
message.zeros[i] = message.zeros[i] | ( (~int(bytes[i])) & 0xff)
|
||||
|
@ -80,7 +80,7 @@ def PrintUnique(interesting_file, background_files):
|
|||
interesting.load(interesting_file)
|
||||
for message_id in sorted(interesting.messages):
|
||||
if message_id not in background.messages:
|
||||
print 'New message_id: %s' % message_id
|
||||
print('New message_id: %s' % message_id)
|
||||
else:
|
||||
interesting.messages[message_id].printBitDiff(
|
||||
background.messages[message_id])
|
||||
|
@ -88,6 +88,6 @@ def PrintUnique(interesting_file, background_files):
|
|||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
print 'Usage:\n%s interesting.csv background*.csv' % sys.argv[0]
|
||||
print('Usage:\n%s interesting.csv background*.csv' % sys.argv[0])
|
||||
sys.exit(0)
|
||||
PrintUnique(sys.argv[1], sys.argv[2:])
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
from panda import Panda
|
||||
|
||||
def get_panda_password():
|
||||
|
@ -17,4 +17,4 @@ def get_panda_password():
|
|||
print("Password: " + wifi[1])
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_panda_password()
|
||||
get_panda_password()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
import struct
|
||||
from panda import Panda
|
||||
|
@ -36,15 +36,15 @@ if __name__ == "__main__":
|
|||
isotp_send(panda, "\x09\x02", 0x7df)
|
||||
ret = isotp_recv(panda, 0x7e8)
|
||||
hexdump(ret)
|
||||
print "VIN: %s" % ret[2:]
|
||||
print("VIN: %s" % ret[2:])
|
||||
|
||||
# 03 = get DTCS
|
||||
isotp_send(panda, "\x03", 0x7e0)
|
||||
dtcs = isotp_recv(panda, 0x7e8)
|
||||
print "DTCs:", dtcs[2:].encode("hex")
|
||||
print("DTCs:", dtcs[2:].encode("hex"))
|
||||
|
||||
supported_pids = get_supported_pids()
|
||||
print "Supported PIDs:",supported_pids
|
||||
print("Supported PIDs:",supported_pids)
|
||||
|
||||
while 1:
|
||||
speed = struct.unpack(">B", get_current_data_for_pid(13)[2:])[0] # kph
|
||||
|
@ -52,7 +52,7 @@ if __name__ == "__main__":
|
|||
throttle = struct.unpack(">B", get_current_data_for_pid(17)[2:])[0]/255.0 * 100 # percent
|
||||
temp = struct.unpack(">B", get_current_data_for_pid(5)[2:])[0] - 40 # degrees C
|
||||
load = struct.unpack(">B", get_current_data_for_pid(4)[2:])[0]/255.0 * 100 # percent
|
||||
print "%d KPH, %d RPM, %.1f%% Throttle, %d deg C, %.1f%% load" % (speed, rpm, throttle, temp, load)
|
||||
print("%d KPH, %d RPM, %.1f%% Throttle, %d deg C, %.1f%% load" % (speed, rpm, throttle, temp, load))
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import binascii
|
||||
from panda import Panda
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# python library to interface with panda
|
||||
from __future__ import print_function
|
||||
|
||||
import binascii
|
||||
import struct
|
||||
import hashlib
|
||||
|
@ -9,12 +9,12 @@ import os
|
|||
import time
|
||||
import traceback
|
||||
import subprocess
|
||||
from dfu import PandaDFU
|
||||
from esptool import ESPROM, CesantaFlasher
|
||||
from flash_release import flash_release
|
||||
from update import ensure_st_up_to_date
|
||||
from serial import PandaSerial
|
||||
from isotp import isotp_send, isotp_recv
|
||||
from .dfu import PandaDFU
|
||||
from .esptool import ESPROM, CesantaFlasher
|
||||
from .flash_release import flash_release
|
||||
from .update import ensure_st_up_to_date
|
||||
from .serial import PandaSerial
|
||||
from .isotp import isotp_send, isotp_recv
|
||||
|
||||
__version__ = '0.0.9'
|
||||
|
||||
|
@ -232,7 +232,7 @@ class Panda(object):
|
|||
def flash_static(handle, code):
|
||||
# confirm flasher is present
|
||||
fr = handle.controlRead(Panda.REQUEST_IN, 0xb0, 0, 0, 0xc)
|
||||
assert fr[4:8] == "\xde\xad\xd0\x0d"
|
||||
assert fr[4:8] == b"\xde\xad\xd0\x0d"
|
||||
|
||||
# unlock flash
|
||||
print("flash: unlocking")
|
||||
|
@ -274,7 +274,7 @@ class Panda(object):
|
|||
fn = os.path.join(BASEDIR, "board", fn)
|
||||
|
||||
if code is None:
|
||||
with open(fn) as f:
|
||||
with open(fn, "rb") as f:
|
||||
code = f.read()
|
||||
|
||||
# get version
|
||||
|
@ -364,7 +364,7 @@ class Panda(object):
|
|||
pass
|
||||
|
||||
def get_version(self):
|
||||
return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40)
|
||||
return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40).decode('utf8')
|
||||
|
||||
def get_type(self):
|
||||
return self._handle.controlRead(Panda.REQUEST_IN, 0xc1, 0, 0, 0x40)
|
||||
|
@ -479,7 +479,7 @@ class Panda(object):
|
|||
break
|
||||
except (usb1.USBErrorIO, usb1.USBErrorOverflow):
|
||||
print("CAN: BAD RECV, RETRYING")
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.1)
|
||||
return parse_can_buffer(dat)
|
||||
|
||||
def can_clear(self, bus):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import usb1
|
||||
import struct
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# NB: Before sending a PR to change the above line to '#!/usr/bin/env python2', please read https://github.com/themadinventor/esptool/issues/21
|
||||
# NB: Before sending a PR to change the above line to '#!/usr/bin/env python3', please read https://github.com/themadinventor/esptool/issues/21
|
||||
#
|
||||
# ESP8266 ROM Bootloader Utility
|
||||
# https://github.com/themadinventor/esptool
|
||||
|
@ -48,7 +48,7 @@ class FakePort(object):
|
|||
|
||||
@baudrate.setter
|
||||
def baudrate(self, x):
|
||||
print "set baud to", x
|
||||
print("set baud to", x)
|
||||
self.panda.set_uart_baud(1, x)
|
||||
|
||||
def write(self, buf):
|
||||
|
@ -114,7 +114,7 @@ class ESPROM(object):
|
|||
|
||||
""" Read a SLIP packet from the serial port """
|
||||
def read(self):
|
||||
return self._slip_reader.next()
|
||||
return next(self._slip_reader)
|
||||
|
||||
""" Write bytes to the serial port while performing SLIP escaping """
|
||||
def write(self, packet):
|
||||
|
@ -140,7 +140,7 @@ class ESPROM(object):
|
|||
# same operation as the request or a retries limit has
|
||||
# exceeded. This is needed for some esp8266s that
|
||||
# reply with more sync responses than expected.
|
||||
for retry in xrange(100):
|
||||
for retry in range(100):
|
||||
p = self.read()
|
||||
if len(p) < 8:
|
||||
continue
|
||||
|
@ -156,14 +156,14 @@ class ESPROM(object):
|
|||
""" Perform a connection test """
|
||||
def sync(self):
|
||||
self.command(ESPROM.ESP_SYNC, '\x07\x07\x12\x20' + 32 * '\x55')
|
||||
for i in xrange(7):
|
||||
for i in range(7):
|
||||
self.command()
|
||||
|
||||
""" Try connecting repeatedly until successful, or giving up """
|
||||
def connect(self):
|
||||
print 'Connecting...'
|
||||
print('Connecting...')
|
||||
|
||||
for _ in xrange(4):
|
||||
for _ in range(4):
|
||||
# issue reset-to-bootloader:
|
||||
# RTS = either CH_PD or nRESET (both active low = chip in reset)
|
||||
# DTR = GPIO0 (active low = boot to flasher)
|
||||
|
@ -180,7 +180,7 @@ class ESPROM(object):
|
|||
|
||||
# worst-case latency timer should be 255ms (probably <20ms)
|
||||
self._port.timeout = 0.3
|
||||
for _ in xrange(4):
|
||||
for _ in range(4):
|
||||
try:
|
||||
self._port.flushInput()
|
||||
self._slip_reader = slip_reader(self._port)
|
||||
|
@ -250,7 +250,7 @@ class ESPROM(object):
|
|||
result = self.command(ESPROM.ESP_FLASH_BEGIN,
|
||||
struct.pack('<IIII', erase_size, num_blocks, ESPROM.ESP_FLASH_BLOCK, offset))[1]
|
||||
if size != 0:
|
||||
print "Took %.2fs to erase flash block" % (time.time() - t)
|
||||
print("Took %.2fs to erase flash block" % (time.time() - t))
|
||||
if result != "\0\0":
|
||||
raise FatalError.WithResult('Failed to enter Flash download mode (result "%s")', result)
|
||||
self._port.timeout = old_tmo
|
||||
|
@ -349,10 +349,10 @@ class ESPROM(object):
|
|||
self.mem_finish(stub['entry'])
|
||||
|
||||
if read_output:
|
||||
print 'Stub executed, reading response:'
|
||||
print('Stub executed, reading response:')
|
||||
while True:
|
||||
p = self.read()
|
||||
print hexify(p)
|
||||
print(hexify(p))
|
||||
if p == '':
|
||||
return
|
||||
|
||||
|
@ -452,7 +452,7 @@ class ESPFirmwareImage(BaseFirmwareImage):
|
|||
if magic != ESPROM.ESP_IMAGE_MAGIC or segments > 16:
|
||||
raise FatalError('Invalid firmware image magic=%d segments=%d' % (magic, segments))
|
||||
|
||||
for i in xrange(segments):
|
||||
for i in range(segments):
|
||||
self.load_segment(load_file)
|
||||
self.checksum = self.read_checksum(load_file)
|
||||
|
||||
|
@ -480,7 +480,7 @@ class OTAFirmwareImage(BaseFirmwareImage):
|
|||
raise FatalError('Invalid V2 image magic=%d' % (magic))
|
||||
if segments != 4:
|
||||
# segment count is not really segment count here, but we expect to see '4'
|
||||
print 'Warning: V2 header has unexpected "segment" count %d (usually 4)' % segments
|
||||
print('Warning: V2 header has unexpected "segment" count %d (usually 4)' % segments)
|
||||
|
||||
# irom segment comes before the second header
|
||||
self.load_segment(load_file, True)
|
||||
|
@ -501,7 +501,7 @@ class OTAFirmwareImage(BaseFirmwareImage):
|
|||
raise FatalError('Invalid V2 second header magic=%d segments=%d' % (magic, segments))
|
||||
|
||||
# load all the usual segments
|
||||
for _ in xrange(segments):
|
||||
for _ in range(segments):
|
||||
self.load_segment(load_file)
|
||||
self.checksum = self.read_checksum(load_file)
|
||||
|
||||
|
@ -543,13 +543,13 @@ class ELFFile(object):
|
|||
tool_nm = "xt-nm"
|
||||
proc = subprocess.Popen([tool_nm, self.name], stdout=subprocess.PIPE)
|
||||
except OSError:
|
||||
print "Error calling %s, do you have Xtensa toolchain in PATH?" % tool_nm
|
||||
print("Error calling %s, do you have Xtensa toolchain in PATH?" % tool_nm)
|
||||
sys.exit(1)
|
||||
for l in proc.stdout:
|
||||
fields = l.strip().split()
|
||||
try:
|
||||
if fields[0] == "U":
|
||||
print "Warning: ELF binary has undefined symbol %s" % fields[1]
|
||||
print("Warning: ELF binary has undefined symbol %s" % fields[1])
|
||||
continue
|
||||
if fields[0] == "w":
|
||||
continue # can skip weak symbols
|
||||
|
@ -568,7 +568,7 @@ class ELFFile(object):
|
|||
try:
|
||||
proc = subprocess.Popen([tool_readelf, "-h", self.name], stdout=subprocess.PIPE)
|
||||
except OSError:
|
||||
print "Error calling %s, do you have Xtensa toolchain in PATH?" % tool_readelf
|
||||
print("Error calling %s, do you have Xtensa toolchain in PATH?" % tool_readelf)
|
||||
sys.exit(1)
|
||||
for l in proc.stdout:
|
||||
fields = l.strip().split()
|
||||
|
@ -599,7 +599,7 @@ class CesantaFlasher(object):
|
|||
CMD_BOOT_FW = 6
|
||||
|
||||
def __init__(self, esp, baud_rate=0):
|
||||
print 'Running Cesanta flasher stub...'
|
||||
print('Running Cesanta flasher stub...')
|
||||
if baud_rate <= ESPROM.ESP_ROM_BAUD: # don't change baud rates if we already synced at that rate
|
||||
baud_rate = 0
|
||||
self._esp = esp
|
||||
|
@ -640,7 +640,7 @@ class CesantaFlasher(object):
|
|||
raise FatalError('Expected digest, got: %s' % hexify(p))
|
||||
digest = hexify(p).upper()
|
||||
expected_digest = hashlib.md5(data).hexdigest().upper()
|
||||
print
|
||||
print()
|
||||
if digest != expected_digest:
|
||||
raise FatalError('Digest mismatch: expected %s, got %s' % (expected_digest, digest))
|
||||
p = self._esp.read()
|
||||
|
@ -679,7 +679,7 @@ class CesantaFlasher(object):
|
|||
raise FatalError('Expected digest, got: %s' % hexify(p))
|
||||
expected_digest = hexify(p).upper()
|
||||
digest = hashlib.md5(data).hexdigest().upper()
|
||||
print
|
||||
print()
|
||||
if digest != expected_digest:
|
||||
raise FatalError('Digest mismatch: expected %s, got %s' % (expected_digest, digest))
|
||||
p = self._esp.read()
|
||||
|
@ -791,7 +791,7 @@ def binutils_safe_path(p):
|
|||
try:
|
||||
return subprocess.check_output(["cygpath", "-w", p]).rstrip('\n')
|
||||
except subprocess.CalledProcessError:
|
||||
print "WARNING: Failed to call cygpath to sanitise Cygwin path."
|
||||
print("WARNING: Failed to call cygpath to sanitise Cygwin path.")
|
||||
return p
|
||||
|
||||
|
||||
|
@ -837,9 +837,9 @@ class FatalError(RuntimeError):
|
|||
def load_ram(esp, args):
|
||||
image = LoadFirmwareImage(args.filename)
|
||||
|
||||
print 'RAM boot...'
|
||||
print('RAM boot...')
|
||||
for (offset, size, data) in image.segments:
|
||||
print 'Downloading %d bytes at %08x...' % (size, offset),
|
||||
print('Downloading %d bytes at %08x...' % (size, offset), end=' ')
|
||||
sys.stdout.flush()
|
||||
esp.mem_begin(size, div_roundup(size, esp.ESP_RAM_BLOCK), esp.ESP_RAM_BLOCK, offset)
|
||||
|
||||
|
@ -848,31 +848,31 @@ def load_ram(esp, args):
|
|||
esp.mem_block(data[0:esp.ESP_RAM_BLOCK], seq)
|
||||
data = data[esp.ESP_RAM_BLOCK:]
|
||||
seq += 1
|
||||
print 'done!'
|
||||
print('done!')
|
||||
|
||||
print 'All segments done, executing at %08x' % image.entrypoint
|
||||
print('All segments done, executing at %08x' % image.entrypoint)
|
||||
esp.mem_finish(image.entrypoint)
|
||||
|
||||
|
||||
def read_mem(esp, args):
|
||||
print '0x%08x = 0x%08x' % (args.address, esp.read_reg(args.address))
|
||||
print('0x%08x = 0x%08x' % (args.address, esp.read_reg(args.address)))
|
||||
|
||||
|
||||
def write_mem(esp, args):
|
||||
esp.write_reg(args.address, args.value, args.mask, 0)
|
||||
print 'Wrote %08x, mask %08x to %08x' % (args.value, args.mask, args.address)
|
||||
print('Wrote %08x, mask %08x to %08x' % (args.value, args.mask, args.address))
|
||||
|
||||
|
||||
def dump_mem(esp, args):
|
||||
f = file(args.filename, 'wb')
|
||||
for i in xrange(args.size / 4):
|
||||
for i in range(args.size / 4):
|
||||
d = esp.read_reg(args.address + (i * 4))
|
||||
f.write(struct.pack('<I', d))
|
||||
if f.tell() % 1024 == 0:
|
||||
print '\r%d bytes read... (%d %%)' % (f.tell(),
|
||||
f.tell() * 100 / args.size),
|
||||
print('\r%d bytes read... (%d %%)' % (f.tell(),
|
||||
f.tell() * 100 / args.size), end=' ')
|
||||
sys.stdout.flush()
|
||||
print 'Done!'
|
||||
print('Done!')
|
||||
|
||||
|
||||
def detect_flash_size(esp, args):
|
||||
|
@ -881,10 +881,10 @@ def detect_flash_size(esp, args):
|
|||
size_id = flash_id >> 16
|
||||
args.flash_size = {18: '2m', 19: '4m', 20: '8m', 21: '16m', 22: '32m'}.get(size_id)
|
||||
if args.flash_size is None:
|
||||
print 'Warning: Could not auto-detect Flash size (FlashID=0x%x, SizeID=0x%x), defaulting to 4m' % (flash_id, size_id)
|
||||
print('Warning: Could not auto-detect Flash size (FlashID=0x%x, SizeID=0x%x), defaulting to 4m' % (flash_id, size_id))
|
||||
args.flash_size = '4m'
|
||||
else:
|
||||
print 'Auto-detected Flash size:', args.flash_size
|
||||
print('Auto-detected Flash size:', args.flash_size)
|
||||
|
||||
|
||||
def write_flash(esp, args):
|
||||
|
@ -900,10 +900,10 @@ def write_flash(esp, args):
|
|||
image = argfile.read()
|
||||
argfile.seek(0) # rewind in case we need it again
|
||||
if address + len(image) > int(args.flash_size.split('m')[0]) * (1 << 17):
|
||||
print 'WARNING: Unlikely to work as data goes beyond end of flash. Hint: Use --flash_size'
|
||||
print('WARNING: Unlikely to work as data goes beyond end of flash. Hint: Use --flash_size')
|
||||
# Fix sflash config data.
|
||||
if address == 0 and image[0] == '\xe9':
|
||||
print 'Flash params set to 0x%02x%02x' % (flash_mode, flash_size_freq)
|
||||
print('Flash params set to 0x%02x%02x' % (flash_mode, flash_size_freq))
|
||||
image = image[0:2] + flash_params + image[4:]
|
||||
# Pad to sector size, which is the minimum unit of writing (erasing really).
|
||||
if len(image) % esp.ESP_FLASH_SECTOR != 0:
|
||||
|
@ -911,11 +911,11 @@ def write_flash(esp, args):
|
|||
t = time.time()
|
||||
flasher.flash_write(address, image, not args.no_progress)
|
||||
t = time.time() - t
|
||||
print ('\rWrote %d bytes at 0x%x in %.1f seconds (%.1f kbit/s)...'
|
||||
print('\rWrote %d bytes at 0x%x in %.1f seconds (%.1f kbit/s)...'
|
||||
% (len(image), address, t, len(image) / t * 8 / 1000))
|
||||
print 'Leaving...'
|
||||
print('Leaving...')
|
||||
if args.verify:
|
||||
print 'Verifying just-written flash...'
|
||||
print('Verifying just-written flash...')
|
||||
_verify_flash(flasher, args, flash_params)
|
||||
flasher.boot_fw()
|
||||
|
||||
|
@ -923,18 +923,18 @@ def write_flash(esp, args):
|
|||
def image_info(args):
|
||||
image = LoadFirmwareImage(args.filename)
|
||||
print('Image version: %d' % image.version)
|
||||
print('Entry point: %08x' % image.entrypoint) if image.entrypoint != 0 else 'Entry point not set'
|
||||
print '%d segments' % len(image.segments)
|
||||
print
|
||||
print(('Entry point: %08x' % image.entrypoint) if image.entrypoint != 0 else 'Entry point not set')
|
||||
print('%d segments' % len(image.segments))
|
||||
print()
|
||||
checksum = ESPROM.ESP_CHECKSUM_MAGIC
|
||||
for (idx, (offset, size, data)) in enumerate(image.segments):
|
||||
if image.version == 2 and idx == 0:
|
||||
print 'Segment 1: %d bytes IROM0 (no load address)' % size
|
||||
print('Segment 1: %d bytes IROM0 (no load address)' % size)
|
||||
else:
|
||||
print 'Segment %d: %5d bytes at %08x' % (idx + 1, size, offset)
|
||||
print('Segment %d: %5d bytes at %08x' % (idx + 1, size, offset))
|
||||
checksum = ESPROM.checksum(data, checksum)
|
||||
print
|
||||
print 'Checksum: %02x (%s)' % (image.checksum, 'valid' if image.checksum == checksum else 'invalid!')
|
||||
print()
|
||||
print('Checksum: %02x (%s)' % (image.checksum, 'valid' if image.checksum == checksum else 'invalid!'))
|
||||
|
||||
|
||||
def make_image(args):
|
||||
|
@ -979,7 +979,7 @@ def elf2image(args):
|
|||
if irom_offs < 0:
|
||||
raise FatalError('Address of symbol _irom0_text_start in ELF is located before flash mapping address. Bad linker script?')
|
||||
if (irom_offs & 0xFFF) != 0: # irom0 isn't flash sector aligned
|
||||
print "WARNING: irom0 section offset is 0x%08x. ELF is probably linked for 'elf2image --version=2'" % irom_offs
|
||||
print("WARNING: irom0 section offset is 0x%08x. ELF is probably linked for 'elf2image --version=2'" % irom_offs)
|
||||
with open(args.output + "0x%05x.bin" % irom_offs, "wb") as f:
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
@ -991,21 +991,21 @@ def elf2image(args):
|
|||
|
||||
def read_mac(esp, args):
|
||||
mac = esp.read_mac()
|
||||
print 'MAC: %s' % ':'.join(map(lambda x: '%02x' % x, mac))
|
||||
print('MAC: %s' % ':'.join(['%02x' % x for x in mac]))
|
||||
|
||||
|
||||
def chip_id(esp, args):
|
||||
chipid = esp.chip_id()
|
||||
print 'Chip ID: 0x%08x' % chipid
|
||||
print('Chip ID: 0x%08x' % chipid)
|
||||
|
||||
|
||||
def erase_flash(esp, args):
|
||||
flasher = CesantaFlasher(esp, args.baud)
|
||||
print 'Erasing flash (this may take a while)...'
|
||||
print('Erasing flash (this may take a while)...')
|
||||
t = time.time()
|
||||
flasher.flash_erase_chip()
|
||||
t = time.time() - t
|
||||
print 'Erase took %.1f seconds' % t
|
||||
print('Erase took %.1f seconds' % t)
|
||||
|
||||
|
||||
def run(esp, args):
|
||||
|
@ -1015,8 +1015,8 @@ def run(esp, args):
|
|||
def flash_id(esp, args):
|
||||
flash_id = esp.flash_id()
|
||||
esp.flash_finish(False)
|
||||
print 'Manufacturer: %02x' % (flash_id & 0xff)
|
||||
print 'Device: %02x%02x' % ((flash_id >> 8) & 0xff, (flash_id >> 16) & 0xff)
|
||||
print('Manufacturer: %02x' % (flash_id & 0xff))
|
||||
print('Device: %02x%02x' % ((flash_id >> 8) & 0xff, (flash_id >> 16) & 0xff))
|
||||
|
||||
|
||||
def read_flash(esp, args):
|
||||
|
@ -1024,7 +1024,7 @@ def read_flash(esp, args):
|
|||
t = time.time()
|
||||
data = flasher.flash_read(args.address, args.size, not args.no_progress)
|
||||
t = time.time() - t
|
||||
print ('\rRead %d bytes at 0x%x in %.1f seconds (%.1f kbit/s)...'
|
||||
print('\rRead %d bytes at 0x%x in %.1f seconds (%.1f kbit/s)...'
|
||||
% (len(data), args.address, t, len(data) / t * 8 / 1000))
|
||||
file(args.filename, 'wb').write(data)
|
||||
|
||||
|
@ -1037,26 +1037,26 @@ def _verify_flash(flasher, args, flash_params=None):
|
|||
if address == 0 and image[0] == '\xe9' and flash_params is not None:
|
||||
image = image[0:2] + flash_params + image[4:]
|
||||
image_size = len(image)
|
||||
print 'Verifying 0x%x (%d) bytes @ 0x%08x in flash against %s...' % (image_size, image_size, address, argfile.name)
|
||||
print('Verifying 0x%x (%d) bytes @ 0x%08x in flash against %s...' % (image_size, image_size, address, argfile.name))
|
||||
# Try digest first, only read if there are differences.
|
||||
digest, _ = flasher.flash_digest(address, image_size)
|
||||
digest = hexify(digest).upper()
|
||||
expected_digest = hashlib.md5(image).hexdigest().upper()
|
||||
if digest == expected_digest:
|
||||
print '-- verify OK (digest matched)'
|
||||
print('-- verify OK (digest matched)')
|
||||
continue
|
||||
else:
|
||||
differences = True
|
||||
if getattr(args, 'diff', 'no') != 'yes':
|
||||
print '-- verify FAILED (digest mismatch)'
|
||||
print('-- verify FAILED (digest mismatch)')
|
||||
continue
|
||||
|
||||
flash = flasher.flash_read(address, image_size)
|
||||
assert flash != image
|
||||
diff = [i for i in xrange(image_size) if flash[i] != image[i]]
|
||||
print '-- verify FAILED: %d differences, first @ 0x%08x' % (len(diff), address + diff[0])
|
||||
diff = [i for i in range(image_size) if flash[i] != image[i]]
|
||||
print('-- verify FAILED: %d differences, first @ 0x%08x' % (len(diff), address + diff[0]))
|
||||
for d in diff:
|
||||
print ' %08x %02x %02x' % (address + d, ord(flash[d]), ord(image[d]))
|
||||
print(' %08x %02x %02x' % (address + d, ord(flash[d]), ord(image[d])))
|
||||
if differences:
|
||||
raise FatalError("Verify failed.")
|
||||
|
||||
|
@ -1067,7 +1067,7 @@ def verify_flash(esp, args, flash_params=None):
|
|||
|
||||
|
||||
def version(args):
|
||||
print __version__
|
||||
print(__version__)
|
||||
|
||||
#
|
||||
# End of operations functions
|
||||
|
@ -1203,12 +1203,12 @@ def main():
|
|||
'version', help='Print esptool version')
|
||||
|
||||
# internal sanity check - every operation matches a module function of the same name
|
||||
for operation in subparsers.choices.keys():
|
||||
for operation in list(subparsers.choices.keys()):
|
||||
assert operation in globals(), "%s should be a module function" % operation
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print 'esptool.py v%s' % __version__
|
||||
print('esptool.py v%s' % __version__)
|
||||
|
||||
# operation function can take 1 arg (args), 2 args (esp, arg)
|
||||
# or be a member function of the ESPROM class.
|
||||
|
@ -1310,5 +1310,5 @@ if __name__ == '__main__':
|
|||
try:
|
||||
main()
|
||||
except FatalError as e:
|
||||
print '\nA fatal error occurred: %s' % e
|
||||
print('\nA fatal error occurred: %s' % e)
|
||||
sys.exit(2)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import time
|
||||
import requests
|
||||
import json
|
||||
import StringIO
|
||||
import io
|
||||
|
||||
def flash_release(path=None, st_serial=None):
|
||||
from panda import Panda, PandaDFU, ESPROM, CesantaFlasher
|
||||
|
@ -29,7 +29,7 @@ def flash_release(path=None, st_serial=None):
|
|||
url = json.loads(r.text)['url']
|
||||
r = requests.get(url)
|
||||
print("Fetching firmware from %s" % url)
|
||||
path = StringIO.StringIO(r.content)
|
||||
path = io.StringIO(r.content)
|
||||
|
||||
zf = ZipFile(path)
|
||||
zf.printdir()
|
||||
|
|
|
@ -2,7 +2,7 @@ DEBUG = False
|
|||
|
||||
def msg(x):
|
||||
if DEBUG:
|
||||
print "S:",x.encode("hex")
|
||||
print("S:",x.encode("hex"))
|
||||
if len(x) <= 7:
|
||||
ret = chr(len(x)) + x
|
||||
else:
|
||||
|
@ -24,7 +24,7 @@ def recv(panda, cnt, addr, nbus):
|
|||
# leave around
|
||||
nmsgs.append((ids, ts, dat, bus))
|
||||
kmsgs = nmsgs[-256:]
|
||||
return map(str, ret)
|
||||
return list(map(str, ret))
|
||||
|
||||
def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr):
|
||||
msg = recv(panda, 1, addr, bus)[0]
|
||||
|
@ -52,7 +52,7 @@ def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr):
|
|||
tlen = ord(msg[1]) & 0xf
|
||||
dat = msg[2:]
|
||||
else:
|
||||
print msg.encode("hex")
|
||||
print(msg.encode("hex"))
|
||||
assert False
|
||||
|
||||
return dat[0:tlen]
|
||||
|
@ -129,7 +129,7 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
|
|||
dat = dat[0:tlen]
|
||||
|
||||
if DEBUG:
|
||||
print "R:",dat.encode("hex")
|
||||
print("R:",dat.encode("hex"))
|
||||
|
||||
return dat
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import time
|
||||
|
||||
|
@ -27,7 +27,7 @@ def ensure_st_up_to_date():
|
|||
panda_dfu = PandaDFU(panda_dfu[0])
|
||||
panda_dfu.recover()
|
||||
|
||||
print "waiting for board..."
|
||||
print("waiting for board...")
|
||||
time.sleep(1)
|
||||
|
||||
if panda.bootstub or not panda.get_version().startswith(repo_version):
|
||||
|
|
|
@ -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,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
|
||||
|
|
|
@ -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
|
||||
|
@ -30,8 +30,8 @@ def test_can_loopback(p):
|
|||
# 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
|
||||
|
||||
|
@ -67,7 +67,7 @@ def test_reliability(p):
|
|||
p.set_can_loopback(True)
|
||||
p.set_can_speed_kbps(0, 1000)
|
||||
|
||||
addrs = range(100, 100+MSG_COUNT)
|
||||
addrs = list(range(100, 100+MSG_COUNT))
|
||||
ts = [(j, 0, "\xaa"*8, 0) for j in addrs]
|
||||
|
||||
# 100 loops
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,7 +4,7 @@ import time
|
|||
import random
|
||||
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
|
||||
|
@ -75,7 +75,7 @@ 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_scan = [x for x in subprocess.check_output(["nmcli","dev", "wifi", "list"]).split("\n") if ssid in x]
|
||||
if len(wifi_scan) != 0:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
@ -153,11 +153,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 +176,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 +185,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 +216,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 +230,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 +247,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 +257,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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
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 pip install pycrypto==2.6.1
|
||||
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
|
||||
|
||||
# Build esp toolchain
|
||||
RUN mkdir -p /panda/boardesp
|
||||
|
@ -14,4 +12,18 @@ RUN CT_ALLOW_BUILD_AS_ROOT_SURE=1 make STANDALONE=y
|
|||
|
||||
COPY . /panda
|
||||
|
||||
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
|
||||
|
||||
RUN pip install pycrypto==2.6.1
|
||||
|
||||
WORKDIR /panda
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
@ -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()
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
from panda import Panda
|
||||
Panda().set_esp_power(False)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import socket
|
||||
import threading
|
||||
import select
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
from panda import Panda
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import time
|
||||
import struct
|
||||
|
@ -67,10 +67,10 @@ if __name__ == "__main__":
|
|||
|
||||
if args.fn:
|
||||
time.sleep(0.1)
|
||||
print "flashing", args.fn
|
||||
print("flashing", args.fn)
|
||||
code = open(args.fn).read()
|
||||
Panda.flash_static(CanHandle(p), code)
|
||||
|
||||
print "can flash done"
|
||||
print("can flash done")
|
||||
|
||||
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
FROM ubuntu:16.04
|
||||
|
||||
RUN apt-get update && apt-get install -y clang make python python-pip
|
||||
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
|
||||
|
||||
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
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cffi==1.11.4
|
||||
numpy==1.14.1
|
||||
numpy==1.14.5
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -183,8 +183,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:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import csv
|
||||
import glob
|
||||
import unittest
|
||||
|
@ -181,8 +181,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:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -282,8 +282,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:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -254,8 +254,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]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -21,8 +21,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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -190,8 +190,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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -174,8 +174,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:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -281,8 +281,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]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import numpy as np
|
||||
import libpandasafety_py
|
||||
|
@ -135,7 +135,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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
import struct
|
||||
import panda.tests.safety.libpandasafety_py as libpandasafety_py
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -25,7 +25,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 +37,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,11 +48,11 @@ 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
|
||||
|
||||
|
@ -64,7 +64,7 @@ if __name__ == "__main__":
|
|||
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)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import requests
|
||||
|
@ -23,7 +23,7 @@ logs = [
|
|||
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 = []
|
||||
|
@ -31,11 +31,11 @@ if __name__ == "__main__":
|
|||
lr = LogReader(route)
|
||||
m = safety_modes.get(mode, mode)
|
||||
|
||||
print "\nreplaying %s with safety mode %d and param %s" % (route, m, param)
|
||||
print("\nreplaying %s with safety mode %d and param %s" % (route, m, param))
|
||||
if not replay_drive(lr, m, 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)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import struct
|
||||
|
|
|
@ -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)))))
|
||||
|
|
|
@ -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]]
|
||||
|
|
Loading…
Reference in New Issue