Skip to content
Permalink
Browse files

openpilot v0.6.6 release

  • Loading branch information...
Vehicle Researcher authored and pd0wm committed Nov 1, 2019
1 parent b4f4b92 commit d7f0b402a878b185dbf65d0a7819f5959dd9b8c2
Showing with 4,191 additions and 3,323 deletions.
  1. +3 −0 .gitignore
  2. +3 −1 Pipfile
  3. +500 −399 Pipfile.lock
  4. +85 −84 README.md
  5. +15 −2 RELEASES.md
  6. +28 −5 SAFETY.md
  7. BIN apk/ai.comma.plus.offroad.apk
  8. +2 −1 check_code_quality.sh
  9. +0 −1 common/kalman/simple_kalman.py
  10. +6 −3 common/params.py
  11. BIN models/driving_model.dlc
  12. BIN models/monitoring_model.dlc
  13. BIN panda/board/obj/panda.bin.signed
  14. BIN phonelibs/yaml-cpp/lib/libyaml-cpp.a
  15. BIN phonelibs/yaml-cpp/x64/lib/libyaml-cpp.a
  16. +13 −10 run_docker_tests.sh
  17. +21 −24 selfdrive/athena/athenad.py
  18. +36 −0 selfdrive/athena/manage_athenad.py
  19. +6 −5 selfdrive/boardd/Makefile
  20. +218 −67 selfdrive/boardd/boardd.cc
  21. +17 −17 selfdrive/boardd/tests/boardd_old.py
  22. +22 −19 selfdrive/boardd/tests/replay_many.py
  23. +2 −3 selfdrive/boardd/tests/test_boardd_loopback.py
  24. +5 −20 selfdrive/can/Makefile
  25. +165 −0 selfdrive/can/common.cc
  26. +54 −3 selfdrive/can/common.h
  27. +71 −0 selfdrive/can/common.pxd
  28. +4 −4 selfdrive/can/dbc_template.cc
  29. +3 −4 selfdrive/can/libdbc_py.py
  30. +2 −6 selfdrive/can/packer.cc
  31. +1 −1 selfdrive/can/packer.py
  32. +158 −595 selfdrive/can/parser.cc
  33. +1 −1 selfdrive/can/parser.py
  34. +0 −98 selfdrive/can/parser_pyx.pxd
  35. +33 −24 selfdrive/can/parser_pyx.pyx
  36. +16 −4 selfdrive/can/parser_pyx_setup.py
  37. +82 −94 selfdrive/can/process_dbc.py
  38. +0 −68 selfdrive/can/tests/packer_old.py
  39. +0 −220 selfdrive/can/tests/parser_old.py
  40. +0 −35 selfdrive/can/tests/test_packer_chrysler.py
  41. +0 −66 selfdrive/can/tests/test_packer_gm.py
  42. +0 −56 selfdrive/can/tests/test_packer_honda.py
  43. +0 −70 selfdrive/can/tests/test_packer_hyundai.py
  44. +92 −0 selfdrive/can/tests/test_packer_parser.py
  45. +0 −37 selfdrive/can/tests/test_packer_subaru.py
  46. +0 −86 selfdrive/can/tests/test_packer_toyota.py
  47. +0 −106 selfdrive/can/tests/test_parser.py
  48. +3 −22 selfdrive/car/car_helpers.py
  49. +1 −8 selfdrive/car/chrysler/carcontroller.py
  50. +8 −0 selfdrive/car/chrysler/values.py
  51. +0 −1 selfdrive/car/gm/interface.py
  52. +0 −16 selfdrive/car/honda/carstate.py
  53. +2 −1 selfdrive/car/honda/values.py
  54. +1 −10 selfdrive/car/hyundai/carcontroller.py
  55. +10 −0 selfdrive/car/hyundai/values.py
  56. +4 −0 selfdrive/car/interfaces.py
  57. +0 −27 selfdrive/car/lock_safety_model.py
  58. +2 −4 selfdrive/car/mock/interface.py
  59. +4 −6 selfdrive/car/subaru/carcontroller.py
  60. +1 −1 selfdrive/car/subaru/carstate.py
  61. +1 −1 selfdrive/car/subaru/values.py
  62. +5 −28 selfdrive/car/toyota/carcontroller.py
  63. +3 −7 selfdrive/car/toyota/interface.py
  64. +0 −6 selfdrive/car/toyota/toyotacan.py
  65. +10 −19 selfdrive/car/toyota/values.py
  66. +3 −4 selfdrive/car/vin.py
  67. +1 −0 selfdrive/car/volkswagen/__init__.py
  68. +188 −0 selfdrive/car/volkswagen/carcontroller.py
  69. +229 −0 selfdrive/car/volkswagen/carstate.py
  70. +242 −0 selfdrive/car/volkswagen/interface.py
  71. +5 −0 selfdrive/car/volkswagen/radar_interface.py
  72. +63 −0 selfdrive/car/volkswagen/values.py
  73. +52 −0 selfdrive/car/volkswagen/volkswagencan.py
  74. +7 −0 selfdrive/common/params.cc
  75. +2 −2 selfdrive/common/utilpp.h
  76. +1 −1 selfdrive/common/version.h
  77. +8 −15 selfdrive/controls/controlsd.py
  78. +16 −9 selfdrive/controls/lib/alerts.py
  79. +8 −0 selfdrive/controls/lib/alerts_offroad.json
  80. +1 −1 selfdrive/controls/lib/latcontrol_indi.py
  81. +2 −8 selfdrive/controls/radard.py
  82. +1 −2 selfdrive/debug/can_printer.py
  83. +6 −43 selfdrive/debug/dump.py
  84. +2 −3 selfdrive/debug/get_fingerprint.py
  85. +3 −4 selfdrive/debug/mpc/live_lateral_mpc.py
  86. +2 −3 selfdrive/debug/mpc/live_longitudinal_mpc.py
  87. +11 −17 selfdrive/locationd/Makefile
  88. +1 −1 selfdrive/locationd/locationd_yawrate.cc
  89. +89 −102 selfdrive/locationd/paramsd.cc
  90. +1 −2 selfdrive/locationd/test/ublox.py
  91. +2 −3 selfdrive/locationd/test/ubloxd.py
  92. +3 −4 selfdrive/locationd/test/ubloxd_easy.py
  93. +0 −1 selfdrive/locationd/ublox_msg.cc
  94. +3 −2 selfdrive/locationd/ublox_msg.h
  95. +12 −10 selfdrive/locationd/ubloxd.cc
  96. +27 −30 selfdrive/locationd/ubloxd_main.cc
  97. +19 −20 selfdrive/locationd/ubloxd_test.cc
  98. +7 −5 selfdrive/logcatd/Makefile
  99. +7 −6 selfdrive/logcatd/logcatd.cc
  100. +6 −2 selfdrive/loggerd/build_from_src.mk
  101. +165 −83 selfdrive/loggerd/encoder.c
  102. +16 −3 selfdrive/loggerd/encoder.h
  103. +62 −107 selfdrive/loggerd/loggerd.cc
  104. +1 −1 selfdrive/loggerd/uploader.py
  105. +1 −2 selfdrive/logmessaged.py
  106. +15 −11 selfdrive/manager.py
  107. +1 −0 selfdrive/messaging/.gitignore
  108. +63 −0 selfdrive/messaging/Makefile
  109. +78 −61 selfdrive/{messaging.py → messaging/__init__.py}
  110. +50 −0 selfdrive/messaging/demo.cc
  111. +30 −0 selfdrive/messaging/demo.py
  112. +173 −0 selfdrive/messaging/impl_zmq.cc
  113. +63 −0 selfdrive/messaging/impl_zmq.hpp
  114. +51 −0 selfdrive/messaging/messaging.cc
  115. +53 −0 selfdrive/messaging/messaging.hpp
  116. +42 −0 selfdrive/messaging/messaging.pxd
  117. +104 −0 selfdrive/messaging/messaging_pyx.pyx
  118. +34 −0 selfdrive/messaging/messaging_pyx_setup.py
  119. +6 −1 selfdrive/pandad.py
  120. +6 −6 selfdrive/proclogd/Makefile
  121. +9 −8 selfdrive/proclogd/proclogd.cc
  122. +10 −8 selfdrive/sensord/build_from_src.mk
  123. +12 −18 selfdrive/sensord/gpsd.cc
  124. +8 −12 selfdrive/sensord/rawgps.cc
  125. +9 −9 selfdrive/sensord/sensors.cc
  126. +10 −11 selfdrive/test/longitudinal_maneuvers/plant.py
  127. +3 −5 selfdrive/test/openpilotci_upload.py
  128. +4 −4 selfdrive/test/process_replay/compare_logs.py
  129. +4 −5 selfdrive/test/process_replay/process_replay.py
  130. +1 −1 selfdrive/test/process_replay/ref_commit
  131. +18 −11 selfdrive/test/test_car_models.py
  132. +27 −1 selfdrive/test/test_fingerprints.py
  133. +49 −9 selfdrive/thermald.py
  134. +14 −6 selfdrive/ui/Makefile
  135. +81 −115 selfdrive/ui/{ui.c → ui.cc}
  136. +6 −1 selfdrive/visiond/build_from_src.mk
  137. +11 −18 selfdrive/visiond/cameras/camera_frame_stream.cc
  138. BIN selfdrive/visiond/dsp/libsnpe_dsp_skel.so
  139. +22 −10 selfdrive/visiond/models/driving.cc
  140. +2 −1 selfdrive/visiond/models/driving.h
  141. +32 −3 selfdrive/visiond/models/monitoring.cc
  142. +4 −2 selfdrive/visiond/models/monitoring.h
  143. +1 −1 selfdrive/visiond/models/posenet.cc
  144. +11 −3 selfdrive/visiond/runners/snpemodel.cc
  145. +5 −1 selfdrive/visiond/runners/snpemodel.h
  146. +10 −4 selfdrive/visiond/snapshot/snapshot.py
  147. +8 −0 selfdrive/visiond/start.py
  148. +57 −85 selfdrive/visiond/visiond.cc
@@ -43,3 +43,6 @@ openpilot
notebooks
xx

.coverage*
htmlcov

@@ -7,6 +7,7 @@ verify_ssl = true
opencv-python= "==3.4.2.17"
PyQt5 = "*"
ipython = "*"
networkx = "*"
azure-common = "*"
azure-nspkg = "*"
azure-storage-blob = "*"
@@ -99,6 +100,7 @@ gast = "==0.2.2"
matplotlib = "*"
dictdiffer = "*"
aenum = "*"
coverage = "*"

[packages]
overpy = {git = "https://github.com/commaai/python-overpy.git",ref = "f86529af402d4642e1faeb146671c40284007323"}
@@ -135,7 +137,7 @@ Flask = "*"
PyJWT = "*"
"Jinja2" = "*"
nose = "*"
pyflakes = "*"
flake8 = "*"
pylint = "*"
pycryptodome = "*"
pillow = "*"

Large diffs are not rendered by default.

169 README.md

Large diffs are not rendered by default.

@@ -1,8 +1,21 @@
Version 0.6.6 (2019-11-05)
========================
* Volkswagen support thanks to jyoung8607!
* Toyota Corolla Hybrid with TSS 2.0 support thanks to u8511049!
* Lexus ES with TSS 2.0 support thanks to energee!
* Fix GM ignition detection and lock safety mode not required anymore
* Log panda firmware and dongle ID thanks to martinl!
* New driving model: improve path prediction and lead detection
* New driver monitoring model, 4x smaller and running on DSP
* Display an alert and don't start openpilot if panda has wrong firmware
* Fix bug preventing EON from terminating processes after a drive
* Remove support for Toyota giraffe without the 120Ohm resistor

Version 0.6.5 (2019-10-07)
========================
* NEOS update: upgrade to Python3 and new installer!
* comma Harness support!
* New driving model: lateral control has lower reliance on lanelines
* New driving model: improve path prediction
* New driver monitoring model: more accurate face and eye detection
* Redesign offroad screen to display updates and alerts
* Increase maximum allowed acceleration
@@ -62,7 +75,7 @@ Version 0.6 (2019-07-01)
* Panda safety code is MISRA compliant and ships with a signed version on release2
* New NEOS is 500MB smaller and has a reproducible usr/pipenv
* Lexus ES Hybrid support thanks to wocsor!
* Improve tuning for supported Toyota with TSS2
* Improve tuning for supported Toyota with TSS 2.0
* Various other stability improvements

Version 0.5.13 (2019-05-31)
@@ -1,8 +1,8 @@
openpilot Safety
======

openpilot is an Adaptive Cruise Control (ACC) and Lane Keeping Assist (LKA) system.
Like other ACC and LKA systems, openpilot requires the driver to be alert and to
openpilot is an Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) system.
Like other ACC and ALC systems, openpilot requires the driver to be alert and to
pay attention at all times. We repeat, **driver alertness is necessary, but not
sufficient, for openpilot to be used safely**.

@@ -93,7 +93,7 @@ GM/Chevrolet
commands outside these limits. A steering torque rate limit is enforced by the panda firmware and by
openpilot, so that the commanded steering torque must rise from 0 to max value no faster than
0.75s. Commanded steering torque is gradually limited by the panda firmware and by openpilot if the driver's
torque exceeds 12 units in the opposite dicrection to ensure limited applied torque against the
torque exceeds 12 units in the opposite direction to ensure limited applied torque against the
driver's will.

- Brake pedal and gas pedal potentiometer signals are contained in the 0xF1 and 0x1A1 CAN messages,
@@ -116,7 +116,7 @@ Hyundai/Kia (Lateral only)
commands outside the values of -409 and 409. A steering torque rate limit is enforced by the panda firmware and by
openpilot, so that the commanded steering torque must rise from 0 to max value no faster than
0.85s. Commanded steering torque is gradually limited by the panda firmware and by openpilot if the driver's
torque exceeds 50 units in the opposite dicrection to ensure limited applied torque against the
torque exceeds 50 units in the opposite direction to ensure limited applied torque against the
driver's will.

Chrysler/Jeep/Fiat (Lateral only)
@@ -144,8 +144,31 @@ Subaru (Lateral only)
commands outside the values of -2047 and 2047. A steering torque rate limit is enforced by the panda firmware and by
openpilot, so that the commanded steering torque must rise from 0 to max value no faster than
0.41s. Commanded steering torque is gradually limited by the panda firmware and by openpilot if the driver's
torque exceeds 60 units in the opposite dicrection to ensure limited applied torque against the
torque exceeds 60 units in the opposite direction to ensure limited applied torque against the
driver's will.

Volkswagen, Audi, SEAT, Škoda (Lateral only)
------

- While the system is engaged, steer commands are subject to the same limits used by the stock system, and
additional limits required to meet Comma safety standards.

- Steering torque is controlled through the CAN message 0x126, also known as HCA_01 for Heading Control Assist.
It's limited by openpilot and Panda to a value between -250 and 250, representing 2.5 Nm of torque applied
at the steering rack. The vehicle EPS unit will fault for values outside -300 and 300.

- The vehicle EPS unit will tolerate any rate of increase or decrease, but may limit the effective rate of
change to 5.0 Nm/s. In accordance with the Comma AI safety model requirements, a rate limit is enforced by
the Panda firmware and by openpilot, so that the commanded steering torque cannot rise from 0 to maximum
faster than 1.25s. Commanded steering torque is gradually limited by the Panda firmware and by openpilot
if the driver's torque exceeds 0.8 Nm in the opposite direction to ensure limited applied torque against
the driver's will.

- Brake and gas pedal pressed signals are contained in the ESP_05 0x106 and Motor_20 0x121 CAN messages,
respectively. A rising edge of either signals triggers a disengagement and is enforced by openpilot.
The cancellation due to the rising edge of the gas pressed signal is also enforced by the Panda firmware.
Additionally, the cruise control system disengages on the rising edge of the brake pedal pressed signal,
and it's enforced by both openpilot and the Panda firmware.

**Extra note**: comma.ai strongly discourages the use of openpilot forks with safety code either missing or
not fully meeting the above requirements.
BIN +9.62 KB (100%) apk/ai.comma.plus.offroad.apk
Binary file not shown.
@@ -1,6 +1,7 @@
#!/bin/bash

pyflakes $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda")
# Only pyflakes checks (--select=F)
flake8 --select=F $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda")
RESULT=$?
if [ $RESULT -eq 0 ]; then
pylint $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda")
@@ -6,5 +6,4 @@
subprocess.check_call(["make", "simple_kalman_impl.so"], cwd=kalman_dir)

from .simple_kalman_impl import KF1D as KF1D
# Silence pyflakes
assert KF1D
@@ -77,10 +77,11 @@ class UnknownKeyName(Exception):
"LiveParameters": [TxType.PERSISTENT],
"LongitudinalControl": [TxType.PERSISTENT],
"OpenpilotEnabledToggle": [TxType.PERSISTENT],
"PandaFirmware": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
"PandaDongleId": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
"Passive": [TxType.PERSISTENT],
"RecordFront": [TxType.PERSISTENT],
"ReleaseNotes": [TxType.PERSISTENT],
"SafetyModelLock": [TxType.PERSISTENT],
"ShouldDoUpdate": [TxType.CLEAR_ON_MANAGER_START],
"SpeedLimitOffset": [TxType.PERSISTENT],
"SubscriberInfo": [TxType.PERSISTENT],
@@ -89,9 +90,11 @@ class UnknownKeyName(Exception):
"UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START],
"Version": [TxType.PERSISTENT],
"Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
"Offroad_TemperatureTooHigh": [TxType.CLEAR_ON_MANAGER_START],
"Offroad_ConnectivityNeededPrompt": [TxType.CLEAR_ON_MANAGER_START],
"Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START],
"Offroad_ConnectivityNeededPrompt": [TxType.CLEAR_ON_MANAGER_START],
"Offroad_TemperatureTooHigh": [TxType.CLEAR_ON_MANAGER_START],
"Offroad_PandaFirmwareMismatch": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
"Offroad_InvalidTime": [TxType.CLEAR_ON_MANAGER_START],
}


BIN +39 Bytes (100%) models/driving_model.dlc
Binary file not shown.
BIN -433 KB (26%) models/monitoring_model.dlc
Binary file not shown.
BIN +2.87 KB (110%) panda/board/obj/panda.bin.signed
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,16 +1,19 @@
#!/bin/bash
set -e

SETUP="cd /tmp/openpilot && make -C cereal && "

docker build -t tmppilot -f Dockerfile.openpilot .

docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/ && ./test_fingerprints.py'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && pyflakes $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda" | grep -vi "^\./tools")'

docker run --rm tmppilot /bin/sh -c "$SETUP cd /tmp/openpilot/selfdrive/test/ && ./test_fingerprints.py"
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && flake8 --select=F $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda" | grep -vi "^\./tools")'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && pylint $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda" | grep -vi "^\./tools"); exit $(($? & 3))'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover common'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/can'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/boardd'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/controls'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && python -m unittest discover selfdrive/loggerd'
docker run --rm -v "$(pwd)"/selfdrive/test/longitudinal_maneuvers/out:/tmp/openpilot/selfdrive/test/longitudinal_maneuvers/out tmppilot /bin/sh -c 'cd /tmp/openpilot/selfdrive/test/longitudinal_maneuvers && OPTEST=1 ./test_longitudinal.py'
docker run --rm tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/process_replay/ && ./test_processes.py'
docker run --rm tmppilot /bin/sh -c 'mkdir -p /data/params && cd /tmp/openpilot/ && make -C cereal && cd /tmp/openpilot/selfdrive/test/ && ./test_car_models.py'
docker run --rm tmppilot /bin/sh -c "$SETUP python -m unittest discover common"
docker run --rm tmppilot /bin/sh -c "$SETUP make -C selfdrive/can -j4 && python -m unittest discover selfdrive/can"
docker run --rm tmppilot /bin/sh -c "$SETUP python -m unittest discover selfdrive/boardd"
docker run --rm tmppilot /bin/sh -c "$SETUP make -C selfdrive/can -j4 && python -m unittest discover selfdrive/controls"
docker run --rm tmppilot /bin/sh -c "$SETUP python -m unittest discover selfdrive/loggerd"
docker run --rm -v "$(pwd)"/selfdrive/test/longitudinal_maneuvers/out:/tmp/openpilot/selfdrive/test/longitudinal_maneuvers/out tmppilot /bin/sh -c "$SETUP make -C selfdrive/can -j4 && cd /tmp/openpilot/selfdrive/test/longitudinal_maneuvers && OPTEST=1 ./test_longitudinal.py"
docker run --rm tmppilot /bin/sh -c "$SETUP make -C selfdrive/can -j4 && cd /tmp/openpilot/selfdrive/test/process_replay/ && ./test_processes.py"
docker run --rm tmppilot /bin/sh -c "$SETUP make -C selfdrive/can -j4 && mkdir -p /data/params && cd /tmp/openpilot/selfdrive/test/ && ./test_car_models.py"
45 selfdrive/athena/athenad.py 100755 → 100644
@@ -10,31 +10,28 @@
import time
import threading
import traceback
import zmq
import base64
import requests
import six.moves.queue
import queue
from functools import partial
from jsonrpc import JSONRPCResponseManager, dispatcher
from websocket import create_connection, WebSocketTimeoutException, ABNF
from selfdrive.loggerd.config import ROOT

import selfdrive.crash as crash
import selfdrive.messaging as messaging
from common.api import Api
from common.params import Params
from selfdrive.services import service_list
from selfdrive.swaglog import cloudlog
from selfdrive.version import version, dirty
from functools import reduce

ATHENA_HOST = os.getenv('ATHENA_HOST', 'wss://athena.comma.ai')
HANDLER_THREADS = os.getenv('HANDLER_THREADS', 4)
LOCAL_PORT_WHITELIST = set([8022])

dispatcher["echo"] = lambda s: s
payload_queue = six.moves.queue.Queue()
response_queue = six.moves.queue.Queue()
payload_queue = queue.Queue()
response_queue = queue.Queue()

def handle_long_poll(ws):
end_event = threading.Event()
@@ -66,7 +63,7 @@ def jsonrpc_handler(end_event):
data = payload_queue.get(timeout=1)
response = JSONRPCResponseManager.handle(data, dispatcher)
response_queue.put_nowait(response)
except six.moves.queue.Empty:
except queue.Empty:
pass
except Exception as e:
cloudlog.exception("athena jsonrpc handler failed")
@@ -79,8 +76,8 @@ def jsonrpc_handler(end_event):
def getMessage(service=None, timeout=1000):
if service is None or service not in service_list:
raise Exception("invalid service")
socket = messaging.sub_sock(service_list[service].port)
socket.setsockopt(zmq.RCVTIMEO, timeout)
socket = messaging.sub_sock(service)
socket.setTimeout(timeout)
ret = messaging.recv_one(socket)
return ret.to_dict()

@@ -99,8 +96,6 @@ def uploadFileToUrl(fn, url, headers):

def startLocalProxy(global_end_event, remote_ws_uri, local_port):
try:
cloudlog.event("athena startLocalProxy", remote_ws_uri=remote_ws_uri, local_port=local_port)

if local_port not in LOCAL_PORT_WHITELIST:
raise Exception("Requested local port not whitelisted")

@@ -169,9 +164,12 @@ def takeSnapshot():
ret = snapshot()
if ret is not None:
def b64jpeg(x):
f = io.BytesIO()
jpeg_write(f, x)
return base64.b64encode(f.getvalue()).decode("utf-8")
if x is not None:
f = io.BytesIO()
jpeg_write(f, x)
return base64.b64encode(f.getvalue()).decode("utf-8")
else:
return None
return {'jpegBack': b64jpeg(ret[0]),
'jpegFront': b64jpeg(ret[1])}
else:
@@ -185,6 +183,7 @@ def ws_proxy_recv(ws, local_sock, ssock, end_event, global_end_event):
except WebSocketTimeoutException:
pass
except Exception:
cloudlog.exception("athenad.ws_proxy_recv.exception")
traceback.print_exc()
break

@@ -208,8 +207,9 @@ def ws_proxy_send(ws, local_sock, signal_sock, end_event):

ws.send(data, ABNF.OPCODE_BINARY)
except Exception:
traceback.print_exc()
end_event.set()
cloudlog.exception("athenad.ws_proxy_send.exception")
traceback.print_exc()
end_event.set()

def ws_recv(ws, end_event):
while not end_event.is_set():
@@ -219,6 +219,7 @@ def ws_recv(ws, end_event):
except WebSocketTimeoutException:
pass
except Exception:
cloudlog.exception("athenad.ws_recv.exception")
traceback.print_exc()
end_event.set()

@@ -227,9 +228,10 @@ def ws_send(ws, end_event):
try:
response = response_queue.get(timeout=1)
ws.send(response.json)
except six.moves.queue.Empty:
except queue.Empty:
pass
except Exception:
cloudlog.exception("athenad.ws_send.exception")
traceback.print_exc()
end_event.set()

@@ -241,31 +243,26 @@ def main(gctx=None):
dongle_id = params.get("DongleId").decode('utf-8')
ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id

crash.bind_user(id=dongle_id)
crash.bind_extra(version=version, dirty=dirty, is_eon=True)
crash.install()

api = Api(dongle_id)

conn_retries = 0
while 1:
try:
print("connecting to %s" % ws_uri)
ws = create_connection(ws_uri,
cookie="jwt=" + api.get_token(),
enable_multithread=True)
cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri)
ws.settimeout(1)
conn_retries = 0
handle_long_poll(ws)
except (KeyboardInterrupt, SystemExit):
break
except Exception:
cloudlog.exception("athenad.main.exception")
conn_retries += 1
traceback.print_exc()

time.sleep(backoff(conn_retries))

params.delete("AthenadPid")

if __name__ == "__main__":
main()
@@ -0,0 +1,36 @@
#!/usr/bin/env python3

import time
from multiprocessing import Process

import selfdrive.crash as crash
from common.params import Params
from selfdrive.manager import launcher
from selfdrive.swaglog import cloudlog
from selfdrive.version import version, dirty

ATHENA_MGR_PID_PARAM = "AthenadPid"

def main():
params = Params()
dongle_id = params.get("DongleId").decode('utf-8')
cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, is_eon=True)
crash.bind_user(id=dongle_id)
crash.bind_extra(version=version, dirty=dirty, is_eon=True)
crash.install()

try:
while 1:
cloudlog.info("starting athena daemon")
proc = Process(name='athenad', target=launcher, args=('selfdrive.athena.athenad',))
proc.start()
proc.join()
cloudlog.event("athenad exited", exitcode=proc.exitcode)
time.sleep(5)
except:
cloudlog.exception("manage_athenad.exception")
finally:
params.delete(ATHENA_MGR_PID_PARAM)

if __name__ == '__main__':
main()

0 comments on commit d7f0b40

Please sign in to comment.
You can’t perform that action at this time.