Skip to content

Commit

Permalink
more Python 3 fixes, attempting to fix jenkins wifi regresison test (c…
Browse files Browse the repository at this point in the history
…ommaai#295)

* more Python 3 fixes, attempting to fix jenkins wifi regresison test. Not successful, but closer.
  • Loading branch information
rbiasini authored Oct 10, 2019
1 parent 2f9e076 commit f9053f5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 21 deletions.
15 changes: 15 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ pipeline {
}
}
}
/*
stage('Test Dev Build (WIFI)') {
steps {
lock(resource: "Pandas", inversePrecedence: true, quantity: 1){
timeout(time: 60, unit: 'MINUTES') {
script {
sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'cd /tmp/panda; ./run_automated_tests.sh'"
sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev.xml"
sh "docker rm ${env.DOCKER_NAME}"
}
}
}
}
}
*/
}
post {
failure {
Expand Down
12 changes: 6 additions & 6 deletions UPDATING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Updating your panda

Panda should update automatically via the [Chffr](http://chffr.comma.ai/) app ([apple](https://itunes.apple.com/us/app/chffr-dash-cam-that-remembers/id1146683979) and [android](https://play.google.com/store/apps/details?id=ai.comma.chffr))
Panda should update automatically via the [openpilot](http://openpilot.comma.ai/).

If it doesn't however, you can use the following commands on linux or Mac OSX
`sudo pip install --upgrade pandacan`
` PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"`

(You'll need to have `pip` and `sudo` installed.)
On Linux or Mac OSX, you can manually update it using:
```
sudo pip install --upgrade pandacan`
PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"`
```
12 changes: 7 additions & 5 deletions examples/query_vin_and_stats.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python3
import time
import struct
import binascii
from panda import Panda
from hexdump import hexdump
from panda.python.isotp import isotp_send, isotp_recv

# 0x7e0 = Toyota
# 0x18DB33F1 for Honda?


def get_current_data_for_pid(pid):
# 01 xx = Show current data
isotp_send(panda, "\x01"+chr(pid), 0x7e0)
isotp_send(panda, b"\x01"+ (chr(pid)).encode("utf8"), 0x7e0)
return isotp_recv(panda, 0x7e8)

def get_supported_pids():
Expand All @@ -33,15 +35,15 @@ def get_supported_pids():
panda.can_clear(0)

# 09 02 = Get VIN
isotp_send(panda, "\x09\x02", 0x7df)
isotp_send(panda, b"\x09\x02", 0x7df)
ret = isotp_recv(panda, 0x7e8)
hexdump(ret)
print("VIN: %s" % ret[2:])
print("VIN: %s" % "".join(map(chr, ret[:2])))

# 03 = get DTCS
isotp_send(panda, "\x03", 0x7e0)
isotp_send(panda, b"\x03", 0x7e0)
dtcs = isotp_recv(panda, 0x7e8)
print("DTCs:", dtcs[2:].encode("hex"))
print("DTCs:", "".join(map(chr, dtcs[:2])))

supported_pids = get_supported_pids()
print("Supported PIDs:",supported_pids)
Expand Down
4 changes: 2 additions & 2 deletions examples/tesla_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def tesla_tester():

# BDY 0x248 is the MCU_commands message, which includes folding mirrors, opening the trunk, frunk, setting the cars lock state and more. For our test, we will edit the 3rd byte, which is MCU_lockRequest. 0x01 will lock, 0x02 will unlock:
print("Unlocking Tesla...")
p.can_send(0x248, "\x00\x00\x02\x00\x00\x00\x00\x00", body_bus_num)
p.can_send(0x248, b"\x00\x00\x02\x00\x00\x00\x00\x00", body_bus_num)

#Or, we can set the first byte, MCU_frontHoodCommand + MCU_liftgateSwitch, to 0x01 to pop the frunk, or 0x04 to open/close the trunk (0x05 should open both)
print("Opening Frunk...")
p.can_send(0x248, "\x01\x00\x00\x00\x00\x00\x00\x00", body_bus_num)
p.can_send(0x248, b"\x01\x00\x00\x00\x00\x00\x00\x00", body_bus_num)

#Back to safety...
print("Disabling output on Panda...")
Expand Down
2 changes: 1 addition & 1 deletion python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def get_serial(self):
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20)
hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4]
assert(hashsig == calc_hash)
return [dat[0:0x10], dat[0x10:0x10+10]]
return [dat[0:0x10].decode("utf8"), dat[0x10:0x10+10].decode("utf8")]

def get_secret(self):
return self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 1, 0, 0x10)
Expand Down
6 changes: 3 additions & 3 deletions python/isotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def msg(x):
if DEBUG:
print("S:", binascii.hexlify(x))
if len(x) <= 7:
ret = chr(len(x)) + x
ret = chr(len(x)).encode("utf8") + x
else:
assert False
return ret.ljust(8, b"\x00")
Expand Down Expand Up @@ -68,7 +68,7 @@ def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None):
if len(x) <= 7 and subaddr is None:
panda.can_send(addr, msg(x), bus)
elif len(x) <= 6 and subaddr is not None:
panda.can_send(addr, chr(subaddr)+msg(x)[0:7], bus)
panda.can_send(addr, chr(subaddr).encode("utf8") + msg(x)[0:7], bus)
else:
if subaddr:
ss = (chr(subaddr) + chr(0x10 + (len(x)>>8)) + chr(len(x)&0xFF)).encode("utf8") + x[0:5]
Expand Down Expand Up @@ -122,7 +122,7 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
assert mm[0] == (0x20 | (idx&0xF))
dat += mm[1:]
idx += 1
elif msg[0]&0xf0 == 0x00:
elif msg[0] & 0xf0 == 0x00:
# single
tlen = msg[0] & 0xf
dat = msg[1:]
Expand Down
8 changes: 4 additions & 4 deletions tests/automated/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def connect_wifi(serial=None):

FNULL = open(os.devnull, 'w')
def _connect_wifi(dongle_id, pw, insecure_okay=False):
ssid = "panda-" + dongle_id.decode("utf8")
ssid = "panda-" + dongle_id

r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT)
if not r:
Expand All @@ -69,7 +69,7 @@ def _connect_wifi(dongle_id, pw, insecure_okay=False):
if sys.platform == "darwin":
os.system("networksetup -setairportnetwork en0 %s %s" % (ssid, pw))
else:
wlan_interface = subprocess.check_output(["sh", "-c", "iw dev | awk '/Interface/ {print $2}'"]).strip()
wlan_interface = subprocess.check_output(["sh", "-c", "iw dev | awk '/Interface/ {print $2}'"]).strip().decode('utf8')
cnt = 0
MAX_TRIES = 10
while cnt < MAX_TRIES:
Expand All @@ -87,13 +87,13 @@ def _connect_wifi(dongle_id, pw, insecure_okay=False):
if "-pair" in wifi_scan[0]:
os.system("nmcli d wifi connect %s-pair" % (ssid))
connect_cnt = 0
MAX_TRIES = 20
MAX_TRIES = 100
while connect_cnt < MAX_TRIES:
connect_cnt += 1
r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT)
if r:
print("Waiting for panda to ping...")
time.sleep(0.1)
time.sleep(0.5)
else:
break
if insecure_okay:
Expand Down

0 comments on commit f9053f5

Please sign in to comment.