Skip to content

Commit

Permalink
return kj::Array<capnp::byte>
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Jan 28, 2021
1 parent 08af344 commit 4df4685
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
10 changes: 4 additions & 6 deletions selfdrive/loggerd/bootlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ int main(int argc, char** argv) {
assert(bzerror == BZ_OK);

// Write initdata
kj::Array<capnp::word> init_msg = logger_build_init_data();
auto bytes = init_msg.asBytes();
BZ2_bzWrite(&bzerror, bz_file, bytes.begin(), bytes.size());
kj::Array<capnp::byte> init_msg = logger_build_init_data();
BZ2_bzWrite(&bzerror, bz_file, init_msg.begin(), init_msg.size());
assert(bzerror == BZ_OK);

// Write bootlog
kj::Array<capnp::word> boot_msg = logger_build_boot();
bytes = boot_msg.asBytes();
BZ2_bzWrite(&bzerror, bz_file, bytes.begin(), bytes.size());
kj::Array<capnp::byte> boot_msg = logger_build_boot();
BZ2_bzWrite(&bzerror, bz_file, boot_msg.begin(), boot_msg.size());
assert(bzerror == BZ_OK);

// Close bz2 and file
Expand Down
13 changes: 6 additions & 7 deletions selfdrive/loggerd/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int logger_mkpath(char* file_path) {
}

// ***** log metadata *****
kj::Array<capnp::word> logger_build_boot() {
kj::Array<capnp::byte> logger_build_boot() {
MessageBuilder msg;
auto boot = msg.initEvent().initBoot();

Expand All @@ -66,10 +66,10 @@ kj::Array<capnp::word> logger_build_boot() {

std::string launchLog = util::read_file("/tmp/launch_log");
boot.setLaunchLog(capnp::Text::Reader(launchLog.data(), launchLog.size()));
return capnp::messageToFlatArray(msg);
return capnp::messageToFlatArray(msg).releaseAsBytes();
}

kj::Array<capnp::word> logger_build_init_data() {
kj::Array<capnp::byte> logger_build_init_data() {
MessageBuilder msg;
auto init = msg.initEvent().initInitData();

Expand Down Expand Up @@ -135,13 +135,12 @@ kj::Array<capnp::word> logger_build_init_data() {
i++;
}
}
return capnp::messageToFlatArray(msg);
return capnp::messageToFlatArray(msg).releaseAsBytes();
}

void log_init_data(LoggerState *s) {
kj::Array<capnp::word> data = logger_build_init_data();
auto bytes = data.asBytes();
logger_log(s, bytes.begin(), bytes.size(), s->has_qlog);
kj::Array<capnp::byte> data = logger_build_init_data();
logger_log(s, data.begin(), data.size(), s->has_qlog);
}


Expand Down
4 changes: 2 additions & 2 deletions selfdrive/loggerd/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ typedef struct LoggerState {
} LoggerState;

int logger_mkpath(char* file_path);
kj::Array<capnp::word> logger_build_boot();
kj::Array<capnp::word> logger_build_init_data();
kj::Array<capnp::byte> logger_build_boot();
kj::Array<capnp::byte> logger_build_init_data();
void logger_init(LoggerState *s, const char* log_name, bool has_qlog);
int logger_next(LoggerState *s, const char* root_path,
char* out_segment_path, size_t out_segment_path_len,
Expand Down

0 comments on commit 4df4685

Please sign in to comment.