sunnylink: Vehicle Selector support (#1587)

* sunnylink: Vehicle Selector support

* shebang
This commit is contained in:
Jason Wen
2025-12-18 00:20:42 -05:00
committed by GitHub
parent f5b3d87e25
commit 2b51adff11
4 changed files with 39 additions and 0 deletions
+1
View File
@@ -139,6 +139,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"BlinkerMinLateralControlSpeed", {PERSISTENT | BACKUP, INT, "20"}}, // MPH or km/h
{"BlinkerPauseLateralControl", {PERSISTENT | BACKUP, INT, "0"}},
{"Brightness", {PERSISTENT | BACKUP, INT, "0"}},
{"CarList", {PERSISTENT, JSON}},
{"CarParamsSP", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BYTES}},
{"CarParamsSPCache", {CLEAR_ON_MANAGER_START, BYTES}},
{"CarParamsSPPersistent", {PERSISTENT, BYTES}},
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
"""
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
import json
import os
from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params
from openpilot.common.swaglog import cloudlog
CAR_LIST_JSON_OUT = os.path.join(BASEDIR, "sunnypilot", "selfdrive", "car", "car_list.json")
def update_car_list_param():
with open(CAR_LIST_JSON_OUT) as f:
current_car_list = json.load(f)
params = Params()
if params.get("CarList") != current_car_list:
params.put("CarList", current_car_list)
cloudlog.warning("Updated CarList param with latest platform list")
else:
cloudlog.warning("CarList param is up to date, no need to update")
if __name__ == "__main__":
update_car_list_param()
@@ -28,6 +28,7 @@ from websocket import (ABNF, WebSocket, WebSocketException, WebSocketTimeoutExce
create_connection, WebSocketConnectionClosedException)
import cereal.messaging as messaging
from openpilot.sunnypilot.selfdrive.car.sync_car_list_param import update_car_list_param
from openpilot.sunnypilot.sunnylink.api import SunnylinkApi
from openpilot.sunnypilot.sunnylink.utils import sunnylink_need_register, sunnylink_ready, get_param_as_byte, save_param_from_base64_encoded_string
@@ -279,6 +280,8 @@ def main(exit_event: threading.Event = None):
sunnylink_api = SunnylinkApi(sunnylink_dongle_id)
UploadQueueCache.initialize(upload_queue)
update_car_list_param()
ws_uri = f"{SUNNYLINK_ATHENA_HOST}"
conn_start = None
conn_retries = 0
@@ -125,6 +125,10 @@
"title": "Car Battery Capacity",
"description": ""
},
"CarList": {
"title": "Supported Car List",
"description": "All supported platform in sunnypilot"
},
"CarParams": {
"title": "Car Params",
"description": ""