From d667d4181ea9c45ed6567206b1ee8188b0bbd618 Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Fri, 7 Jan 2022 11:55:35 +0100 Subject: [PATCH 1/4] two detection --- selfdrive/boardd/boardd.cc | 2 ++ selfdrive/common/params.cc | 1 + selfdrive/hardware/eon/hardware.py | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 0ca943de2e84f7..1178b4cafa8823 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -658,6 +658,8 @@ int main(int argc, char *argv[]) { Panda *peripheral_panda = pandas[0]; std::vector threads; + Params().put("LastPeripheralPandaType", std::to_string((int) peripheral_panda->get_hw_type())); + threads.emplace_back(panda_state_thread, &pm, pandas, getenv("STARTED") != nullptr); threads.emplace_back(peripheral_control_thread, peripheral_panda); threads.emplace_back(pigeon_thread, peripheral_panda); diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index f0508cace0f205..39cb4fcfae98b0 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -131,6 +131,7 @@ std::unordered_map keys = { {"JoystickDebugMode", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, {"LastAthenaPingTime", CLEAR_ON_MANAGER_START}, {"LastGPSPosition", PERSISTENT}, + {"LastPeripheralPandaType", PERSISTENT}, {"LastPowerDropDetected", CLEAR_ON_MANAGER_START}, {"LastUpdateException", PERSISTENT}, {"LastUpdateTime", PERSISTENT}, diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py index fa275c5a9c7ef8..ddccfcdcff36e2 100644 --- a/selfdrive/hardware/eon/hardware.py +++ b/selfdrive/hardware/eon/hardware.py @@ -8,6 +8,7 @@ from typing import List, Union from cereal import log +from common.params import Params from selfdrive.hardware.base import HardwareBase, ThermalConfig NetworkType = log.DeviceState.NetworkType @@ -70,6 +71,9 @@ def get_os_version(self): return f.read().strip() def get_device_type(self): + peripheral_panda = Params().get("LastPeripheralPandaType") + if peripheral_panda is not None and int(peripheral_panda) == log.PandaState.PandaType.uno: + return "two" return "eon" def get_sound_card_online(self): From f5219a7497f261b2c02cc7ef01e9b3ef232f8352 Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Mon, 10 Jan 2022 11:40:24 +0100 Subject: [PATCH 2/4] fix CI --- selfdrive/hardware/eon/hardware.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py index ddccfcdcff36e2..1c3c5e43525cf7 100644 --- a/selfdrive/hardware/eon/hardware.py +++ b/selfdrive/hardware/eon/hardware.py @@ -8,9 +8,14 @@ from typing import List, Union from cereal import log -from common.params import Params from selfdrive.hardware.base import HardwareBase, ThermalConfig +try: + from common.params import Params +except ModuleNotFoundError: + # openpilot is not built yet + Params = None + NetworkType = log.DeviceState.NetworkType NetworkStrength = log.DeviceState.NetworkStrength @@ -71,9 +76,10 @@ def get_os_version(self): return f.read().strip() def get_device_type(self): - peripheral_panda = Params().get("LastPeripheralPandaType") - if peripheral_panda is not None and int(peripheral_panda) == log.PandaState.PandaType.uno: - return "two" + if Params is not None: + peripheral_panda = Params().get("LastPeripheralPandaType") + if peripheral_panda is not None and int(peripheral_panda) == log.PandaState.PandaType.uno: + return "two" return "eon" def get_sound_card_online(self): From 82171f8ee75f9b8992f1ae1b27c2654526032261 Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Mon, 10 Jan 2022 12:08:13 +0100 Subject: [PATCH 3/4] catch all --- selfdrive/hardware/eon/hardware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py index 1c3c5e43525cf7..16368ca09fca65 100644 --- a/selfdrive/hardware/eon/hardware.py +++ b/selfdrive/hardware/eon/hardware.py @@ -12,7 +12,7 @@ try: from common.params import Params -except ModuleNotFoundError: +except Exception: # openpilot is not built yet Params = None From 5aa208a9e61043ae0b4914cd8c9d35c7a41d5bc2 Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Mon, 10 Jan 2022 12:12:56 +0100 Subject: [PATCH 4/4] gotta catch em all --- selfdrive/hardware/eon/hardware.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py index 16368ca09fca65..4ab9f81fcf26cd 100644 --- a/selfdrive/hardware/eon/hardware.py +++ b/selfdrive/hardware/eon/hardware.py @@ -76,10 +76,11 @@ def get_os_version(self): return f.read().strip() def get_device_type(self): - if Params is not None: - peripheral_panda = Params().get("LastPeripheralPandaType") - if peripheral_panda is not None and int(peripheral_panda) == log.PandaState.PandaType.uno: + try: + if int(Params().get("LastPeripheralPandaType")) == log.PandaState.PandaType.uno: return "two" + except Exception: + pass return "eon" def get_sound_card_online(self):