mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 07:22:04 +08:00
use put_nonblocking when possible (#1288)
* use put_nonblocking when possible * revert uneeded changes
This commit is contained in:
@@ -2,7 +2,7 @@ from cereal import car
|
||||
from selfdrive.config import Conversions as CV
|
||||
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
|
||||
from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES
|
||||
from common.params import Params
|
||||
from common.params import put_nonblocking
|
||||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
|
||||
@@ -79,7 +79,6 @@ class CarInterface(CarInterfaceBase):
|
||||
def update(self, c, can_strings):
|
||||
canMonoTimes = []
|
||||
buttonEvents = []
|
||||
params = Params()
|
||||
|
||||
# Process the most recent CAN message traffic, and check for validity
|
||||
# The camera CAN has no signals we use at this time, but we process it
|
||||
@@ -94,7 +93,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# Update the EON metric configuration to match the car at first startup,
|
||||
# or if there's been a change.
|
||||
if self.CS.displayMetricUnits != self.displayMetricUnitsPrev:
|
||||
params.put("IsMetric", "1" if self.CS.displayMetricUnits else "0")
|
||||
put_nonblocking("IsMetric", "1" if self.CS.displayMetricUnits else "0")
|
||||
|
||||
# Check for and process state-change events (button press or release) from
|
||||
# the turn stalk switch or ACC steering wheel/control stalk buttons.
|
||||
|
||||
@@ -6,7 +6,7 @@ from cereal import car, log
|
||||
from common.numpy_fast import clip
|
||||
from common.realtime import sec_since_boot, set_realtime_priority, Ratekeeper, DT_CTRL
|
||||
from common.profiler import Profiler
|
||||
from common.params import Params
|
||||
from common.params import Params, put_nonblocking
|
||||
import cereal.messaging as messaging
|
||||
from selfdrive.config import Conversions as CV
|
||||
from selfdrive.boardd.boardd import can_list_to_can_capnp
|
||||
@@ -490,8 +490,8 @@ def controlsd_thread(sm=None, pm=None, can_sock=None):
|
||||
# Write CarParams for radard and boardd safety mode
|
||||
cp_bytes = CP.to_bytes()
|
||||
params.put("CarParams", cp_bytes)
|
||||
params.put("CarParamsCache", cp_bytes)
|
||||
params.put("LongitudinalControl", "1" if CP.openpilotLongitudinalControl else "0")
|
||||
put_nonblocking("CarParamsCache", cp_bytes)
|
||||
put_nonblocking("LongitudinalControl", "1" if CP.openpilotLongitudinalControl else "0")
|
||||
|
||||
CC = car.CarControl.new_message()
|
||||
AM = AlertManager()
|
||||
|
||||
@@ -8,7 +8,7 @@ from smbus2 import SMBus
|
||||
from cereal import log
|
||||
from common.android import ANDROID, get_network_type, get_network_strength
|
||||
from common.basedir import BASEDIR
|
||||
from common.params import Params
|
||||
from common.params import Params, put_nonblocking
|
||||
from common.realtime import sec_since_boot, DT_TRML
|
||||
from common.numpy_fast import clip, interp
|
||||
from common.filter_simple import FirstOrderFilter
|
||||
@@ -268,7 +268,7 @@ def thermald_thread():
|
||||
if time_valid and not time_valid_prev:
|
||||
params.delete("Offroad_InvalidTime")
|
||||
if not time_valid and time_valid_prev:
|
||||
params.put("Offroad_InvalidTime", json.dumps(OFFROAD_ALERTS["Offroad_InvalidTime"]))
|
||||
put_nonblocking("Offroad_InvalidTime", json.dumps(OFFROAD_ALERTS["Offroad_InvalidTime"]))
|
||||
time_valid_prev = time_valid
|
||||
|
||||
# Show update prompt
|
||||
@@ -285,7 +285,7 @@ def thermald_thread():
|
||||
if current_connectivity_alert != "expired":
|
||||
current_connectivity_alert = "expired"
|
||||
params.delete("Offroad_ConnectivityNeededPrompt")
|
||||
params.put("Offroad_ConnectivityNeeded", json.dumps(OFFROAD_ALERTS["Offroad_ConnectivityNeeded"]))
|
||||
put_nonblocking("Offroad_ConnectivityNeeded", json.dumps(OFFROAD_ALERTS["Offroad_ConnectivityNeeded"]))
|
||||
elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT:
|
||||
remaining_time = str(max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 0))
|
||||
if current_connectivity_alert != "prompt" + remaining_time:
|
||||
@@ -293,7 +293,7 @@ def thermald_thread():
|
||||
alert_connectivity_prompt = copy.copy(OFFROAD_ALERTS["Offroad_ConnectivityNeededPrompt"])
|
||||
alert_connectivity_prompt["text"] += remaining_time + " days."
|
||||
params.delete("Offroad_ConnectivityNeeded")
|
||||
params.put("Offroad_ConnectivityNeededPrompt", json.dumps(alert_connectivity_prompt))
|
||||
put_nonblocking("Offroad_ConnectivityNeededPrompt", json.dumps(alert_connectivity_prompt))
|
||||
elif current_connectivity_alert is not None:
|
||||
current_connectivity_alert = None
|
||||
params.delete("Offroad_ConnectivityNeeded")
|
||||
@@ -331,14 +331,14 @@ def thermald_thread():
|
||||
if fw_version_match and not fw_version_match_prev:
|
||||
params.delete("Offroad_PandaFirmwareMismatch")
|
||||
if not fw_version_match and fw_version_match_prev:
|
||||
params.put("Offroad_PandaFirmwareMismatch", json.dumps(OFFROAD_ALERTS["Offroad_PandaFirmwareMismatch"]))
|
||||
put_nonblocking("Offroad_PandaFirmwareMismatch", json.dumps(OFFROAD_ALERTS["Offroad_PandaFirmwareMismatch"]))
|
||||
|
||||
# if any CPU gets above 107 or the battery gets above 63, kill all processes
|
||||
# controls will warn with CPU above 95 or battery above 60
|
||||
if thermal_status >= ThermalStatus.danger:
|
||||
should_start = False
|
||||
if thermal_status_prev < ThermalStatus.danger:
|
||||
params.put("Offroad_TemperatureTooHigh", json.dumps(OFFROAD_ALERTS["Offroad_TemperatureTooHigh"]))
|
||||
put_nonblocking("Offroad_TemperatureTooHigh", json.dumps(OFFROAD_ALERTS["Offroad_TemperatureTooHigh"]))
|
||||
else:
|
||||
if thermal_status_prev >= ThermalStatus.danger:
|
||||
params.delete("Offroad_TemperatureTooHigh")
|
||||
@@ -354,7 +354,7 @@ def thermald_thread():
|
||||
os.system('echo performance > /sys/class/devfreq/soc:qcom,cpubw/governor')
|
||||
else:
|
||||
if should_start_prev or (count == 0):
|
||||
params.put("IsOffroad", "1")
|
||||
put_nonblocking("IsOffroad", "1")
|
||||
|
||||
started_ts = None
|
||||
if off_ts is None:
|
||||
@@ -379,7 +379,7 @@ def thermald_thread():
|
||||
thermal_sock.send(msg.to_bytes())
|
||||
|
||||
if usb_power_prev and not usb_power:
|
||||
params.put("Offroad_ChargeDisabled", json.dumps(OFFROAD_ALERTS["Offroad_ChargeDisabled"]))
|
||||
put_nonblocking("Offroad_ChargeDisabled", json.dumps(OFFROAD_ALERTS["Offroad_ChargeDisabled"]))
|
||||
elif usb_power and not usb_power_prev:
|
||||
params.delete("Offroad_ChargeDisabled")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user