use put_nonblocking when possible (#1288)

* use put_nonblocking when possible

* revert uneeded changes
pull/1298/head
eFini 5 years ago committed by GitHub
parent 3cb1568a54
commit 106be23c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      selfdrive/car/volkswagen/interface.py
  2. 6
      selfdrive/controls/controlsd.py
  3. 16
      selfdrive/thermald/thermald.py

@ -2,7 +2,7 @@ from cereal import car
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES 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 import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
@ -79,7 +79,6 @@ class CarInterface(CarInterfaceBase):
def update(self, c, can_strings): def update(self, c, can_strings):
canMonoTimes = [] canMonoTimes = []
buttonEvents = [] buttonEvents = []
params = Params()
# Process the most recent CAN message traffic, and check for validity # 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 # 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, # Update the EON metric configuration to match the car at first startup,
# or if there's been a change. # or if there's been a change.
if self.CS.displayMetricUnits != self.displayMetricUnitsPrev: 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 # Check for and process state-change events (button press or release) from
# the turn stalk switch or ACC steering wheel/control stalk buttons. # 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.numpy_fast import clip
from common.realtime import sec_since_boot, set_realtime_priority, Ratekeeper, DT_CTRL from common.realtime import sec_since_boot, set_realtime_priority, Ratekeeper, DT_CTRL
from common.profiler import Profiler from common.profiler import Profiler
from common.params import Params from common.params import Params, put_nonblocking
import cereal.messaging as messaging import cereal.messaging as messaging
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
from selfdrive.boardd.boardd import can_list_to_can_capnp 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 # Write CarParams for radard and boardd safety mode
cp_bytes = CP.to_bytes() cp_bytes = CP.to_bytes()
params.put("CarParams", cp_bytes) params.put("CarParams", cp_bytes)
params.put("CarParamsCache", cp_bytes) put_nonblocking("CarParamsCache", cp_bytes)
params.put("LongitudinalControl", "1" if CP.openpilotLongitudinalControl else "0") put_nonblocking("LongitudinalControl", "1" if CP.openpilotLongitudinalControl else "0")
CC = car.CarControl.new_message() CC = car.CarControl.new_message()
AM = AlertManager() AM = AlertManager()

@ -8,7 +8,7 @@ from smbus2 import SMBus
from cereal import log from cereal import log
from common.android import ANDROID, get_network_type, get_network_strength from common.android import ANDROID, get_network_type, get_network_strength
from common.basedir import BASEDIR 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.realtime import sec_since_boot, DT_TRML
from common.numpy_fast import clip, interp from common.numpy_fast import clip, interp
from common.filter_simple import FirstOrderFilter from common.filter_simple import FirstOrderFilter
@ -268,7 +268,7 @@ def thermald_thread():
if time_valid and not time_valid_prev: if time_valid and not time_valid_prev:
params.delete("Offroad_InvalidTime") params.delete("Offroad_InvalidTime")
if not time_valid and time_valid_prev: 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 time_valid_prev = time_valid
# Show update prompt # Show update prompt
@ -285,7 +285,7 @@ def thermald_thread():
if current_connectivity_alert != "expired": if current_connectivity_alert != "expired":
current_connectivity_alert = "expired" current_connectivity_alert = "expired"
params.delete("Offroad_ConnectivityNeededPrompt") 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: elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT:
remaining_time = str(max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 0)) remaining_time = str(max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 0))
if current_connectivity_alert != "prompt" + remaining_time: 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 = copy.copy(OFFROAD_ALERTS["Offroad_ConnectivityNeededPrompt"])
alert_connectivity_prompt["text"] += remaining_time + " days." alert_connectivity_prompt["text"] += remaining_time + " days."
params.delete("Offroad_ConnectivityNeeded") 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: elif current_connectivity_alert is not None:
current_connectivity_alert = None current_connectivity_alert = None
params.delete("Offroad_ConnectivityNeeded") params.delete("Offroad_ConnectivityNeeded")
@ -331,14 +331,14 @@ def thermald_thread():
if fw_version_match and not fw_version_match_prev: if fw_version_match and not fw_version_match_prev:
params.delete("Offroad_PandaFirmwareMismatch") params.delete("Offroad_PandaFirmwareMismatch")
if not fw_version_match and fw_version_match_prev: 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 # 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 # controls will warn with CPU above 95 or battery above 60
if thermal_status >= ThermalStatus.danger: if thermal_status >= ThermalStatus.danger:
should_start = False should_start = False
if thermal_status_prev < ThermalStatus.danger: 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: else:
if thermal_status_prev >= ThermalStatus.danger: if thermal_status_prev >= ThermalStatus.danger:
params.delete("Offroad_TemperatureTooHigh") params.delete("Offroad_TemperatureTooHigh")
@ -354,7 +354,7 @@ def thermald_thread():
os.system('echo performance > /sys/class/devfreq/soc:qcom,cpubw/governor') os.system('echo performance > /sys/class/devfreq/soc:qcom,cpubw/governor')
else: else:
if should_start_prev or (count == 0): if should_start_prev or (count == 0):
params.put("IsOffroad", "1") put_nonblocking("IsOffroad", "1")
started_ts = None started_ts = None
if off_ts is None: if off_ts is None:
@ -379,7 +379,7 @@ def thermald_thread():
thermal_sock.send(msg.to_bytes()) thermal_sock.send(msg.to_bytes())
if usb_power_prev and not usb_power: 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: elif usb_power and not usb_power_prev:
params.delete("Offroad_ChargeDisabled") params.delete("Offroad_ChargeDisabled")

Loading…
Cancel
Save