Skip to content

Commit

Permalink
loggerd: log HW-specific extras (commaai#28084)
Browse files Browse the repository at this point in the history
* loggerd: log HW-specific extras

* fix value

---------

Co-authored-by: Comma Device <[email protected]>
  • Loading branch information
adeebshihadeh and Comma Device authored May 9, 2023
1 parent 78ba67e commit e24d28f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions system/hardware/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class HardwareNone {

static std::string get_serial() { return "cccccc"; }

static std::map<std::string, std::string> get_init_logs() {
return {};
}

static void reboot() {}
static void poweroff() {}
static void set_brightness(int percent) {}
Expand Down
7 changes: 7 additions & 0 deletions system/hardware/tici/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class HardwareTici : public HardwareNone {
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 void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); };
};
12 changes: 11 additions & 1 deletion system/loggerd/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ kj::Array<capnp::word> logger_build_init_data() {
"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++) {
auto lentry = commands[i];

Expand All @@ -80,6 +82,14 @@ kj::Array<capnp::word> logger_build_init_data() {
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);
}

Expand Down

0 comments on commit e24d28f

Please sign in to comment.