Skip to content

Fix C3 for Tesla power off after few hours bugs - #409

Merged
ajouatom merged 3 commits into
ajouatom:c3-wipfrom
navipilot:c3-wip
Jun 22, 2026
Merged

ajouatom merged 3 commits into
ajouatom:c3-wipfrom
navipilot:c3-wip

Conversation

@navipilot

Copy link
Copy Markdown
Contributor

check IQ and SP code and tested pass

                                                                                                                                             
    - Detect stock AEB (DAS_aebEvent) and trigger PERMANENT alert + safety layer                                                             
      blocking longitudinal commands                                                                                                         
    - Detect stock steering control (DAS_steeringControlType != NONE) and block                                                              
      lateral commands at the panda safety layer, unconditionally respecting                                                                 
      DAS emergency evasive steering                                                                                                         
    - Both mechanisms act as a hardware-level safety firewall
Copilot AI review requested due to automatic review settings June 22, 2026 12:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modifies hardwared’s offroad power-management behavior to avoid unintended power-saving and auto-shutdown on Tesla vehicles (where CAN can remain powered while parked), which can otherwise lead to the device powering off after extended parked periods.

Changes:

  • Add a lightweight CarParams cache to detect whether the current vehicle brand is Tesla.
  • Make power-save decisions based on ignition + screen brightness, with a Tesla exception (never power save).
  • Skip auto-shutdown on Tesla by gating power_monitor.should_shutdown(...) on the Tesla detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +194 to +197
cp_bytes = params.get("CarParams")
if not cp_bytes or cp_bytes == self._last_bytes:
return
self._last_bytes = cp_bytes

# Power save decision: independent of should_start
# For Tesla: never power save (CAN stays alive when parked)
should_pwrsave = (not tesla_no_sleep) and (not onroad_conditions["ignition"] and msg.deviceState.screenBrightnessPercent < 1e-3)
Comment on lines +425 to +428
# On Tesla, keep started_ts valid even when parked so the manager
# does NOT kill selfdrive/controls processes (CAN stays alive).
if tesla_no_sleep and started_ts is None and started_seen:
started_ts = time.monotonic()
@ajouatom
ajouatom merged commit e7f764b into ajouatom:c3-wip Jun 22, 2026
4 of 15 checks passed
ChanHoya pushed a commit that referenced this pull request Jun 24, 2026
* Handle stock AEB and active steering avoidance by disengaging openpilot                                                                  
                                                                                                                                             
    - Detect stock AEB (DAS_aebEvent) and trigger PERMANENT alert + safety layer                                                             
      blocking longitudinal commands                                                                                                         
    - Detect stock steering control (DAS_steeringControlType != NONE) and block                                                              
      lateral commands at the panda safety layer, unconditionally respecting                                                                 
      DAS emergency evasive steering                                                                                                         
    - Both mechanisms act as a hardware-level safety firewall

* fix C3 on Tesla will not power off
happymaj11r pushed a commit to happymaj11r/openpilot that referenced this pull request Jun 25, 2026
* Handle stock AEB and active steering avoidance by disengaging openpilot

    - Detect stock AEB (DAS_aebEvent) and trigger PERMANENT alert + safety layer
      blocking longitudinal commands
    - Detect stock steering control (DAS_steeringControlType != NONE) and block
      lateral commands at the panda safety layer, unconditionally respecting
      DAS emergency evasive steering
    - Both mechanisms act as a hardware-level safety firewall

* fix C3 on Tesla will not power off

(cherry picked from commit e7f764b)
Donfyffe pushed a commit to Donfyffe/openpilot that referenced this pull request Jun 26, 2026
* Handle stock AEB and active steering avoidance by disengaging openpilot                                                                  
                                                                                                                                             
    - Detect stock AEB (DAS_aebEvent) and trigger PERMANENT alert + safety layer                                                             
      blocking longitudinal commands                                                                                                         
    - Detect stock steering control (DAS_steeringControlType != NONE) and block                                                              
      lateral commands at the panda safety layer, unconditionally respecting                                                                 
      DAS emergency evasive steering                                                                                                         
    - Both mechanisms act as a hardware-level safety firewall

* fix C3 on Tesla will not power off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants