Skip to content

Commit

Permalink
Merge pull request commaai#122 from pacasrc/0.8.10.no_offroad_fix
Browse files Browse the repository at this point in the history
patch no_offroad_fix for autoshutdown
  • Loading branch information
eFiniLan authored Feb 10, 2022
2 parents b88aa72 + 223271d commit e668101
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/dp_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
{'name': 'dp_nav_amap_key_2', 'default': '', 'type': 'Text', 'conf_type': ['param']},
{'name': 'dp_nav_style_day', 'default': 'mapbox://styles/rav4kumar/ckv7dtfba6oik15r0w8dh1c1q', 'type': 'Text', 'conf_type': ['param']},
{'name': 'dp_nav_style_night', 'default': 'mapbox://styles/rav4kumar/ckvsf3f4u0zb414tcz9vof5jc', 'type': 'Text', 'conf_type': ['param']},
{'name': 'dp_no_offroad_fix', 'default': False, 'type': 'Bool', 'conf_type': ['param']},
]

# from 0.8.9 to 0.8.10
Expand Down
1 change: 1 addition & 0 deletions selfdrive/common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"dp_nav_amap_key_2", PERSISTENT},
{"dp_nav_style_day", PERSISTENT},
{"dp_nav_style_night", PERSISTENT},
{"dp_no_offroad_fix", PERSISTENT},
};

} // namespace
Expand Down
13 changes: 13 additions & 0 deletions selfdrive/thermald/thermald.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def thermald_thread():
params.put_bool("BootedOnroad", True)

# dp
peripheralStateLast = None
dp_no_batt = params.get_bool("dp_no_batt")
dp_temp_monitor = True
dp_last_modified_temp_monitor = None
Expand All @@ -268,6 +269,7 @@ def thermald_thread():
last_modified = None
last_modified_check = None

dp_no_offroad_fix = params.get_bool('dp_no_offroad_fix')
if JETSON:
handle_fan = handle_fan_jetson

Expand Down Expand Up @@ -469,6 +471,9 @@ def thermald_thread():

# Handle offroad/onroad transition
should_start = all(startup_conditions.values())
# dp - check usb_present to fix not going offroad on "EON/LEON + battery - Comma Power"
if dp_no_offroad_fix:
should_start = should_start and HARDWARE.get_usb_present()
if should_start != should_start_prev or (count == 0):
params.put_bool("IsOnroad", should_start)
params.put_bool("IsOffroad", not should_start)
Expand Down Expand Up @@ -496,6 +501,14 @@ def thermald_thread():
# Check if we need to disable charging (handled by boardd)
msg.deviceState.chargingDisabled = power_monitor.should_disable_charging(startup_conditions["ignition"], in_car, off_ts, dp_auto_shutdown, dp_auto_shutdown_in)

# dp - for battery powered device
# when peripheralState is not changing (panda offline), and usb is not present (not charging)
if dp_no_offroad_fix and (peripheralStateLast == peripheralState) and not msg.deviceState.usbOnline:
if (sec_since_boot() - off_ts) > dp_auto_shutdown_in * 60:
time.sleep(10)
HARDWARE.shutdown()
peripheralStateLast = peripheralState

# Check if we need to shut down
if power_monitor.should_shutdown(peripheralState, startup_conditions["ignition"], in_car, off_ts, started_seen, LEON, dp_auto_shutdown, dp_auto_shutdown_in):
cloudlog.info(f"shutting device down, offroad since {off_ts}")
Expand Down

0 comments on commit e668101

Please sign in to comment.