diff --git a/common/dp_conf.py b/common/dp_conf.py index 9cff4f2b8..f1414a510 100644 --- a/common/dp_conf.py +++ b/common/dp_conf.py @@ -125,6 +125,7 @@ confs = [ {'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 diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index ae33c00d3..1ad35e445 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -299,6 +299,7 @@ std::unordered_map keys = { {"dp_nav_amap_key_2", PERSISTENT}, {"dp_nav_style_day", PERSISTENT}, {"dp_nav_style_night", PERSISTENT}, + {"dp_no_offroad_fix", PERSISTENT}, }; } // namespace diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 8ebfcec0f..af4290009 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -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 @@ -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 @@ -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) @@ -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}")