mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-23 01:13:44 +08:00
thermald: save last offroad status packet on onroad transition (#28563)
* thermald: save last offroad status packet on onroad transition * update param * write every time --------- Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: 7d6897fa38be4bc6f82f35b902052b12efd47af3
This commit is contained in:
@@ -151,6 +151,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"LiveParameters", PERSISTENT},
|
||||
{"LiveTorqueCarParams", PERSISTENT},
|
||||
{"LiveTorqueParameters", PERSISTENT | DONT_LOG},
|
||||
{"LastOffroadStatusPacket", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION},
|
||||
{"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION},
|
||||
{"NavDestinationWaypoints", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION},
|
||||
{"NavSettingTime24h", PERSISTENT},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import datetime
|
||||
import os
|
||||
import json
|
||||
import queue
|
||||
import threading
|
||||
import time
|
||||
@@ -375,8 +376,6 @@ def thermald_thread(end_event, hw_queue):
|
||||
msg.deviceState.thermalStatus = thermal_status
|
||||
pm.send("deviceState", msg)
|
||||
|
||||
should_start_prev = should_start
|
||||
|
||||
# Log to statsd
|
||||
statlog.gauge("free_space_percent", msg.deviceState.freeSpacePercent)
|
||||
statlog.gauge("gpu_usage_percent", msg.deviceState.gpuUsagePercent)
|
||||
@@ -399,15 +398,26 @@ def thermald_thread(end_event, hw_queue):
|
||||
statlog.gauge("screen_brightness_percent", msg.deviceState.screenBrightnessPercent)
|
||||
|
||||
# report to server once every 10 minutes
|
||||
if (count % int(600. / DT_TRML)) == 0:
|
||||
cloudlog.event("STATUS_PACKET",
|
||||
count=count,
|
||||
pandaStates=[strip_deprecated_keys(p.to_dict()) for p in pandaStates],
|
||||
peripheralState=strip_deprecated_keys(peripheralState.to_dict()),
|
||||
location=(strip_deprecated_keys(sm["gpsLocationExternal"].to_dict()) if sm.alive["gpsLocationExternal"] else None),
|
||||
deviceState=strip_deprecated_keys(msg.to_dict()))
|
||||
rising_edge_started = should_start and not should_start_prev
|
||||
if rising_edge_started or (count % int(600. / DT_TRML)) == 0:
|
||||
dat = {
|
||||
'count': count,
|
||||
'pandaStates': [strip_deprecated_keys(p.to_dict()) for p in pandaStates],
|
||||
'peripheralState': strip_deprecated_keys(peripheralState.to_dict()),
|
||||
'location': (strip_deprecated_keys(sm["gpsLocationExternal"].to_dict()) if sm.alive["gpsLocationExternal"] else None),
|
||||
'deviceState': strip_deprecated_keys(msg.to_dict())
|
||||
}
|
||||
cloudlog.event("STATUS_PACKET", **dat)
|
||||
|
||||
# save last one before going onroad
|
||||
if rising_edge_started:
|
||||
try:
|
||||
params.put("LastOffroadStatusPacket", json.dumps(dat))
|
||||
except Exception:
|
||||
cloudlog.exception("failed to save offroad status")
|
||||
|
||||
count += 1
|
||||
should_start_prev = should_start
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user