mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 18:53:55 +08:00
* less TICI when not needed * fix process replay * move reading voltages into hw abstraction layer * Update selfdrive/hardware/tici/hardware.h Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/hardware/hw.h Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Update selfdrive/hardware/base.h Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * rename init function * Update selfdrive/athena/athenad.py Co-authored-by: Robbe Derks <robbe.derks@gmail.com> * Update selfdrive/boardd/boardd.cc * Apply suggestions from code review * Update selfdrive/thermald/thermald.py * update ref * fix alert width if all cameras are bad * add ecam to test_loggerd * bump cereal * bump cereal Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Robbe Derks <robbe.derks@gmail.com>
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#include <cassert>
|
|
#include <string>
|
|
|
|
#include "cereal/messaging/messaging.h"
|
|
#include "common/swaglog.h"
|
|
#include "selfdrive/loggerd/logger.h"
|
|
|
|
|
|
static kj::Array<capnp::word> build_boot_log() {
|
|
std::vector<std::string> bootlog_commands;
|
|
if (Hardware::AGNOS()) {
|
|
bootlog_commands.push_back("journalctl");
|
|
bootlog_commands.push_back("sudo nvme smart-log --output-format=json /dev/nvme0");
|
|
}
|
|
|
|
MessageBuilder msg;
|
|
auto boot = msg.initEvent().initBoot();
|
|
|
|
boot.setWallTimeNanos(nanos_since_epoch());
|
|
|
|
std::string pstore = "/sys/fs/pstore";
|
|
std::map<std::string, std::string> pstore_map = util::read_files_in_dir(pstore);
|
|
|
|
int i = 0;
|
|
auto lpstore = boot.initPstore().initEntries(pstore_map.size());
|
|
for (auto& kv : pstore_map) {
|
|
auto lentry = lpstore[i];
|
|
lentry.setKey(kv.first);
|
|
lentry.setValue(capnp::Data::Reader((const kj::byte*)kv.second.data(), kv.second.size()));
|
|
i++;
|
|
}
|
|
|
|
// Gather output of commands
|
|
i = 0;
|
|
auto commands = boot.initCommands().initEntries(bootlog_commands.size());
|
|
for (auto &command : bootlog_commands) {
|
|
auto lentry = commands[i];
|
|
|
|
lentry.setKey(command);
|
|
|
|
const std::string result = util::check_output(command);
|
|
lentry.setValue(capnp::Data::Reader((const kj::byte*)result.data(), result.size()));
|
|
|
|
i++;
|
|
}
|
|
|
|
boot.setLaunchLog(util::read_file("/tmp/launch_log"));
|
|
return capnp::messageToFlatArray(msg);
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
const std::string path = LOG_ROOT + "/boot/" + logger_get_route_name();
|
|
LOGW("bootlog to %s", path.c_str());
|
|
|
|
// Open bootlog
|
|
bool r = util::create_directories(LOG_ROOT + "/boot/", 0775);
|
|
assert(r);
|
|
|
|
RawFile bz_file(path.c_str());
|
|
|
|
// Write initdata
|
|
bz_file.write(logger_build_init_data().asBytes());
|
|
|
|
// Write bootlog
|
|
bz_file.write(build_boot_log().asBytes());
|
|
|
|
return 0;
|
|
}
|