mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-03 23:24:36 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 741d9f7604 | |||
| b7dd946fa2 | |||
| d44645fc53 | |||
| 2f2692d515 | |||
| d7aa0f5002 | |||
| a763c93496 | |||
| cf0c41af96 | |||
| 34e35d49e1 | |||
| a5ec1b3f16 | |||
| b7c40b4c44 | |||
| 4033119fa0 | |||
| 7bb32de4b8 | |||
| 7419b2a0b0 | |||
| aa8a190f5a |
+1
-1
Submodule opendbc_repo updated: f9f1223de9...f95f996f59
@@ -139,6 +139,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"ChestnutActive", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_IGNITION_ON, BOOL}},
|
||||
{"ChestnutLoading", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_IGNITION_ON, BOOL}},
|
||||
{"ChestnutModelError", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_IGNITION_ON, BOOL}},
|
||||
{"AuxPowerSave", {PERSISTENT | BACKUP, BOOL}},
|
||||
{"Version", {PERSISTENT, STRING}},
|
||||
|
||||
// --- sunnypilot params --- //
|
||||
|
||||
@@ -576,7 +576,7 @@ class SelfdriveD(CruiseHelper):
|
||||
clear_event_types = set()
|
||||
if ET.WARNING not in self.state_machine.current_alert_types:
|
||||
clear_event_types.add(ET.WARNING)
|
||||
if self.enabled or self.mads.clear_no_entry:
|
||||
if self.enabled:
|
||||
clear_event_types.add(ET.NO_ENTRY)
|
||||
|
||||
pers = LONGITUDINAL_PERSONALITY_MAP[self.personality]
|
||||
|
||||
@@ -225,6 +225,7 @@ class UIState(UIStateSP):
|
||||
ChestnutState.UNCOMPILED if detected else ChestnutState.DISCONNECTED)
|
||||
return
|
||||
|
||||
self.chestnut_present = self.chestnut_present or detected
|
||||
model_seen = self.sm.recv_frame["modelV2"] > self.started_frame
|
||||
if not self.chestnut_present:
|
||||
self.chestnut_state = ChestnutState.DISCONNECTED
|
||||
|
||||
@@ -10,7 +10,6 @@ from openpilot.cereal import log, custom
|
||||
from opendbc.car import structs
|
||||
from opendbc.car.hyundai.values import HyundaiFlags
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.selfdrive.selfdrived.events import ET
|
||||
from openpilot.sunnypilot.mads.helpers import MadsSteeringModeOnBrake, read_steering_mode_param, MADS_NO_ACC_MAIN_BUTTON
|
||||
from openpilot.sunnypilot.mads.state import StateMachine, GEARS_ALLOW_PAUSED_SILENT
|
||||
|
||||
@@ -34,7 +33,6 @@ class ModularAssistiveDrivingSystem:
|
||||
self.enabled = False
|
||||
self.active = False
|
||||
self.available = False
|
||||
self.clear_no_entry = False
|
||||
self.lateral_mismatch_counter = 0
|
||||
self.allow_always = False
|
||||
self.no_main_cruise = False
|
||||
@@ -220,8 +218,5 @@ class ModularAssistiveDrivingSystem:
|
||||
if not self.CP.passive and self.selfdrive.initialized:
|
||||
self.enabled, self.active = self.state_machine.update()
|
||||
|
||||
cat = self.selfdrive.state_machine.current_alert_types
|
||||
self.clear_no_entry = (ET.ENABLE in cat or ET.USER_DISABLE in cat) and ET.NO_ENTRY not in cat
|
||||
|
||||
# Copy of previous SelfdriveD states for MADS events handling
|
||||
self.selfdrive.enabled_prev = self.selfdrive.enabled
|
||||
|
||||
@@ -1675,6 +1675,12 @@
|
||||
"widget": "toggle",
|
||||
"title": "Onroad Uploads"
|
||||
},
|
||||
{
|
||||
"key": "AuxPowerSave",
|
||||
"widget": "toggle",
|
||||
"title": "Disable Aux Port When Offroad",
|
||||
"description": "Power off the aux USB-C port while offroad to save power. It powers back on automatically when you go onroad."
|
||||
},
|
||||
{
|
||||
"key": "MaxTimeOffroad",
|
||||
"widget": "option",
|
||||
|
||||
@@ -30,6 +30,10 @@ sections:
|
||||
- key: OnroadUploads
|
||||
widget: toggle
|
||||
title: Onroad Uploads
|
||||
- key: AuxPowerSave
|
||||
widget: toggle
|
||||
title: Disable Aux Port When Offroad
|
||||
description: Power off the aux USB-C port while offroad to save power. It powers back on automatically when you go onroad.
|
||||
- key: MaxTimeOffroad
|
||||
widget: option
|
||||
title: Max Time Offroad
|
||||
|
||||
@@ -21,6 +21,7 @@ from openpilot.common.hardware import HARDWARE, COMMA_HARDWARE
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.common.git import get_short_branch
|
||||
from openpilot.common.hardware.usb import CHESTNUT_FW_VERSION, CHESTNUT_USB_PRODUCT, get_usb_state, get_usb_topology, is_chestnut_usb_id, set_usb_state
|
||||
from openpilot.system.hardware.chestnut.flash import VBUS_PATH
|
||||
from openpilot.common.linux import LinuxSystemStats
|
||||
from openpilot.system.loggerd.config import get_available_percent
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
@@ -50,6 +51,10 @@ class Chestnut:
|
||||
self.last_attempt = 0.
|
||||
self.flashed = False
|
||||
self.mismatch = False
|
||||
self.vbus_on = None
|
||||
self.params = Params()
|
||||
self.powersave = False
|
||||
self.last_offroad = None
|
||||
|
||||
@property
|
||||
def failed(self) -> bool:
|
||||
@@ -61,9 +66,19 @@ class Chestnut:
|
||||
cloudlog.event("chestnut flash done", returncode=ret.returncode, output=ret.stdout[-1000:], error=ret.returncode != 0)
|
||||
self.flashed = ret.returncode == 0
|
||||
|
||||
def set_vbus(self, on: bool) -> None:
|
||||
if on == self.vbus_on:
|
||||
return
|
||||
subprocess.run(["sudo", "tee", VBUS_PATH], input=b"1" if on else b"0", stdout=subprocess.DEVNULL, check=False)
|
||||
self.vbus_on = on
|
||||
|
||||
def update(self, offroad: bool, usb_state: list[dict]) -> None:
|
||||
self.mismatch = any(is_chestnut_usb_id(d["vendorId"], d["productId"], include_bootloader=True) and
|
||||
d["product"] != CHESTNUT_USB_PRODUCT for d in usb_state)
|
||||
if offroad != self.last_offroad:
|
||||
self.powersave = self.params.get_bool("AuxPowerSave")
|
||||
self.last_offroad = offroad
|
||||
self.set_vbus((not offroad or self.mismatch) or not self.powersave)
|
||||
if not self.mismatch:
|
||||
self.flashed = False
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user