loggerd: log HW-specific extras (#28084)

* loggerd: log HW-specific extras

* fix value

---------

Co-authored-by: Comma Device <device@comma.ai>
pull/28146/head
Adeeb Shihadeh 2 years ago committed by GitHub
parent 78ba67e211
commit e24d28fd45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      system/hardware/base.h
  2. 7
      system/hardware/tici/hardware.h
  3. 12
      system/loggerd/logger.cc

@ -18,6 +18,10 @@ public:
static std::string get_serial() { return "cccccc"; } static std::string get_serial() { return "cccccc"; }
static std::map<std::string, std::string> get_init_logs() {
return {};
}
static void reboot() {} static void reboot() {}
static void poweroff() {} static void poweroff() {}
static void set_brightness(int percent) {} static void set_brightness(int percent) {}

@ -73,6 +73,13 @@ public:
std::system(("pactl set-sink-volume @DEFAULT_SINK@ " + std::string(volume_str)).c_str()); std::system(("pactl set-sink-volume @DEFAULT_SINK@ " + std::string(volume_str)).c_str());
} }
static std::map<std::string, std::string> get_init_logs() {
return {
{"/BUILD", util::read_file("/BUILD")},
};
}
static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); }; static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); };
static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); }; static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); };
}; };

@ -70,7 +70,9 @@ kj::Array<capnp::word> logger_build_init_data() {
"df -h", // usage for all filesystems "df -h", // usage for all filesystems
}; };
auto commands = init.initCommands().initEntries(log_commands.size()); auto hw_logs = Hardware::get_init_logs();
auto commands = init.initCommands().initEntries(log_commands.size() + hw_logs.size());
for (int i = 0; i < log_commands.size(); i++) { for (int i = 0; i < log_commands.size(); i++) {
auto lentry = commands[i]; auto lentry = commands[i];
@ -80,6 +82,14 @@ kj::Array<capnp::word> logger_build_init_data() {
lentry.setValue(capnp::Data::Reader((const kj::byte*)result.data(), result.size())); lentry.setValue(capnp::Data::Reader((const kj::byte*)result.data(), result.size()));
} }
int i = log_commands.size();
for (auto [key, value] : hw_logs) {
auto lentry = commands[i];
lentry.setKey(key);
lentry.setValue(capnp::Data::Reader((const kj::byte*)value.data(), value.size()));
i++;
}
return capnp::messageToFlatArray(msg); return capnp::messageToFlatArray(msg);
} }

Loading…
Cancel
Save