Skip to content

Commit f9053f5

Browse files
authoredOct 10, 2019
more Python 3 fixes, attempting to fix jenkins wifi regresison test (#295)
* more Python 3 fixes, attempting to fix jenkins wifi regresison test. Not successful, but closer.
1 parent 2f9e076 commit f9053f5

File tree

7 files changed

+38
-21
lines changed

7 files changed

+38
-21
lines changed
 

‎Jenkinsfile

+15
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ pipeline {
4646
}
4747
}
4848
}
49+
/*
50+
stage('Test Dev Build (WIFI)') {
51+
steps {
52+
lock(resource: "Pandas", inversePrecedence: true, quantity: 1){
53+
timeout(time: 60, unit: 'MINUTES') {
54+
script {
55+
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'"
56+
sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev.xml"
57+
sh "docker rm ${env.DOCKER_NAME}"
58+
}
59+
}
60+
}
61+
}
62+
}
63+
*/
4964
}
5065
post {
5166
failure {

‎UPDATING.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Updating your panda
22

3-
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))
3+
Panda should update automatically via the [openpilot](http://openpilot.comma.ai/).
44

5-
If it doesn't however, you can use the following commands on linux or Mac OSX
6-
`sudo pip install --upgrade pandacan`
7-
` PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"`
8-
9-
(You'll need to have `pip` and `sudo` installed.)
5+
On Linux or Mac OSX, you can manually update it using:
6+
```
7+
sudo pip install --upgrade pandacan`
8+
PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"`
9+
```

‎examples/query_vin_and_stats.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/usr/bin/env python3
22
import time
33
import struct
4+
import binascii
45
from panda import Panda
56
from hexdump import hexdump
67
from panda.python.isotp import isotp_send, isotp_recv
78

89
# 0x7e0 = Toyota
910
# 0x18DB33F1 for Honda?
1011

12+
1113
def get_current_data_for_pid(pid):
1214
# 01 xx = Show current data
13-
isotp_send(panda, "\x01"+chr(pid), 0x7e0)
15+
isotp_send(panda, b"\x01"+ (chr(pid)).encode("utf8"), 0x7e0)
1416
return isotp_recv(panda, 0x7e8)
1517

1618
def get_supported_pids():
@@ -33,15 +35,15 @@ def get_supported_pids():
3335
panda.can_clear(0)
3436

3537
# 09 02 = Get VIN
36-
isotp_send(panda, "\x09\x02", 0x7df)
38+
isotp_send(panda, b"\x09\x02", 0x7df)
3739
ret = isotp_recv(panda, 0x7e8)
3840
hexdump(ret)
39-
print("VIN: %s" % ret[2:])
41+
print("VIN: %s" % "".join(map(chr, ret[:2])))
4042

4143
# 03 = get DTCS
42-
isotp_send(panda, "\x03", 0x7e0)
44+
isotp_send(panda, b"\x03", 0x7e0)
4345
dtcs = isotp_recv(panda, 0x7e8)
44-
print("DTCs:", dtcs[2:].encode("hex"))
46+
print("DTCs:", "".join(map(chr, dtcs[:2])))
4547

4648
supported_pids = get_supported_pids()
4749
print("Supported PIDs:",supported_pids)

‎examples/tesla_tester.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def tesla_tester():
2929

3030
# 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:
3131
print("Unlocking Tesla...")
32-
p.can_send(0x248, "\x00\x00\x02\x00\x00\x00\x00\x00", body_bus_num)
32+
p.can_send(0x248, b"\x00\x00\x02\x00\x00\x00\x00\x00", body_bus_num)
3333

3434
#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)
3535
print("Opening Frunk...")
36-
p.can_send(0x248, "\x01\x00\x00\x00\x00\x00\x00\x00", body_bus_num)
36+
p.can_send(0x248, b"\x01\x00\x00\x00\x00\x00\x00\x00", body_bus_num)
3737

3838
#Back to safety...
3939
print("Disabling output on Panda...")

‎python/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def get_serial(self):
387387
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20)
388388
hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4]
389389
assert(hashsig == calc_hash)
390-
return [dat[0:0x10], dat[0x10:0x10+10]]
390+
return [dat[0:0x10].decode("utf8"), dat[0x10:0x10+10].decode("utf8")]
391391

392392
def get_secret(self):
393393
return self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 1, 0, 0x10)

‎python/isotp.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def msg(x):
66
if DEBUG:
77
print("S:", binascii.hexlify(x))
88
if len(x) <= 7:
9-
ret = chr(len(x)) + x
9+
ret = chr(len(x)).encode("utf8") + x
1010
else:
1111
assert False
1212
return ret.ljust(8, b"\x00")
@@ -68,7 +68,7 @@ def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None):
6868
if len(x) <= 7 and subaddr is None:
6969
panda.can_send(addr, msg(x), bus)
7070
elif len(x) <= 6 and subaddr is not None:
71-
panda.can_send(addr, chr(subaddr)+msg(x)[0:7], bus)
71+
panda.can_send(addr, chr(subaddr).encode("utf8") + msg(x)[0:7], bus)
7272
else:
7373
if subaddr:
7474
ss = (chr(subaddr) + chr(0x10 + (len(x)>>8)) + chr(len(x)&0xFF)).encode("utf8") + x[0:5]
@@ -122,7 +122,7 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
122122
assert mm[0] == (0x20 | (idx&0xF))
123123
dat += mm[1:]
124124
idx += 1
125-
elif msg[0]&0xf0 == 0x00:
125+
elif msg[0] & 0xf0 == 0x00:
126126
# single
127127
tlen = msg[0] & 0xf
128128
dat = msg[1:]

‎tests/automated/helpers.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def connect_wifi(serial=None):
5050

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

5555
r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT)
5656
if not r:
@@ -69,7 +69,7 @@ def _connect_wifi(dongle_id, pw, insecure_okay=False):
6969
if sys.platform == "darwin":
7070
os.system("networksetup -setairportnetwork en0 %s %s" % (ssid, pw))
7171
else:
72-
wlan_interface = subprocess.check_output(["sh", "-c", "iw dev | awk '/Interface/ {print $2}'"]).strip()
72+
wlan_interface = subprocess.check_output(["sh", "-c", "iw dev | awk '/Interface/ {print $2}'"]).strip().decode('utf8')
7373
cnt = 0
7474
MAX_TRIES = 10
7575
while cnt < MAX_TRIES:
@@ -87,13 +87,13 @@ def _connect_wifi(dongle_id, pw, insecure_okay=False):
8787
if "-pair" in wifi_scan[0]:
8888
os.system("nmcli d wifi connect %s-pair" % (ssid))
8989
connect_cnt = 0
90-
MAX_TRIES = 20
90+
MAX_TRIES = 100
9191
while connect_cnt < MAX_TRIES:
9292
connect_cnt += 1
9393
r = subprocess.call(["ping", "-W", "4", "-c", "1", "192.168.0.10"], stdout=FNULL, stderr=subprocess.STDOUT)
9494
if r:
9595
print("Waiting for panda to ping...")
96-
time.sleep(0.1)
96+
time.sleep(0.5)
9797
else:
9898
break
9999
if insecure_okay:

0 commit comments

Comments
 (0)