Dynamic device type (#28011)
* tizi_device_type * fix test * also change it in the C versin old-commit-hash: 21bcd7db630d5abb41f00e3e9d3a025c26337a92
This commit is contained in:
2
cereal
2
cereal
Submodule cereal updated: 37157b1364...b448a8295d
@@ -16,8 +16,16 @@ public:
|
||||
static std::string get_os_version() {
|
||||
return "AGNOS " + util::read_file("/VERSION");
|
||||
};
|
||||
static std::string get_name() { return "tici"; };
|
||||
static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::TICI; };
|
||||
|
||||
static std::string get_name() {
|
||||
std::string devicetree_model = util::read_file("/sys/firmware/devicetree/base/model");
|
||||
return (devicetree_model.find("tizi") != std::string::npos) ? "tizi" : "tici";
|
||||
};
|
||||
|
||||
static cereal::InitData::DeviceType get_device_type() {
|
||||
return (get_name() == "tizi") ? cereal::InitData::DeviceType::TIZI : cereal::InitData::DeviceType::TICI;
|
||||
};
|
||||
|
||||
static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); };
|
||||
static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); };
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
import subprocess
|
||||
import time
|
||||
from enum import IntEnum
|
||||
from functools import cached_property
|
||||
from functools import cached_property, lru_cache
|
||||
from pathlib import Path
|
||||
|
||||
from cereal import log
|
||||
@@ -91,8 +91,12 @@ class Tici(HardwareBase):
|
||||
def amplifier(self):
|
||||
return Amplifier()
|
||||
|
||||
@cached_property
|
||||
def model(self):
|
||||
def get_os_version(self):
|
||||
with open("/VERSION") as f:
|
||||
return f.read().strip()
|
||||
|
||||
@lru_cache
|
||||
def get_device_type(self):
|
||||
with open("/sys/firmware/devicetree/base/model") as f:
|
||||
model = f.read().strip('\x00')
|
||||
model = model.split('comma ')[-1]
|
||||
@@ -101,13 +105,6 @@ class Tici(HardwareBase):
|
||||
model = 'tici'
|
||||
return model
|
||||
|
||||
def get_os_version(self):
|
||||
with open("/VERSION") as f:
|
||||
return f.read().strip()
|
||||
|
||||
def get_device_type(self):
|
||||
return "tici"
|
||||
|
||||
def get_sound_card_online(self):
|
||||
return (os.path.isfile('/proc/asound/card0/state') and
|
||||
open('/proc/asound/card0/state').read().strip() == 'ONLINE')
|
||||
@@ -424,7 +421,7 @@ class Tici(HardwareBase):
|
||||
# amplifier, 100mW at idle
|
||||
self.amplifier.set_global_shutdown(amp_disabled=powersave_enabled)
|
||||
if not powersave_enabled:
|
||||
self.amplifier.initialize_configuration(self.model)
|
||||
self.amplifier.initialize_configuration(self.get_device_type())
|
||||
|
||||
# *** CPU config ***
|
||||
|
||||
@@ -445,7 +442,7 @@ class Tici(HardwareBase):
|
||||
# boardd core
|
||||
affine_irq(4, "spi_geni") # SPI
|
||||
affine_irq(4, "xhci-hcd:usb3") # aux panda USB (or potentially anything else on USB)
|
||||
if "tici" in self.model:
|
||||
if "tici" in self.get_device_type():
|
||||
affine_irq(4, "xhci-hcd:usb1") # internal panda USB
|
||||
|
||||
# camerad core
|
||||
@@ -461,7 +458,7 @@ class Tici(HardwareBase):
|
||||
return 0
|
||||
|
||||
def initialize_hardware(self):
|
||||
self.amplifier.initialize_configuration(self.model)
|
||||
self.amplifier.initialize_configuration(self.get_device_type())
|
||||
|
||||
# Allow thermald to write engagement status to kmsg
|
||||
os.system("sudo chmod a+w /dev/kmsg")
|
||||
|
||||
@@ -38,7 +38,7 @@ class TestAmplifier(unittest.TestCase):
|
||||
|
||||
def test_init(self):
|
||||
amp = Amplifier(debug=True)
|
||||
r = amp.initialize_configuration(Tici().model)
|
||||
r = amp.initialize_configuration(Tici().get_device_type())
|
||||
assert r
|
||||
self._check_for_i2c_errors(False)
|
||||
|
||||
@@ -59,7 +59,7 @@ class TestAmplifier(unittest.TestCase):
|
||||
time.sleep(random.randint(0, 5))
|
||||
|
||||
amp = Amplifier(debug=True)
|
||||
r = amp.initialize_configuration(Tici().model)
|
||||
r = amp.initialize_configuration(Tici().get_device_type())
|
||||
assert r
|
||||
|
||||
# make sure we're a good test
|
||||
|
||||
Reference in New Issue
Block a user