Revert "use class AlignedBuffer from cereal (#20343)"

This reverts commit 7aa379e123.
pull/20378/head
Willem Melching 4 years ago
parent 1c83ae8722
commit e3ad952902
  1. 15
      selfdrive/boardd/boardd.cc
  2. 9
      selfdrive/locationd/ubloxd_main.cc
  3. 12
      selfdrive/loggerd/loggerd.cc

@ -99,7 +99,11 @@ void safety_setter_thread() {
}
LOGW("got %d bytes CarParams", params.size());
capnp::FlatArrayMessageReader cmsg(AlignedBuffer(params.data(), params.size()));
// format for board, make copy due to alignment issues, will be freed on out of scope
auto amsg = kj::heapArray<capnp::word>((params.size() / sizeof(capnp::word)) + 1);
memcpy(amsg.begin(), params.data(), params.size());
capnp::FlatArrayMessageReader cmsg(amsg);
cereal::CarParams::Reader car_params = cmsg.getRoot<cereal::CarParams>();
cereal::CarParams::SafetyModel safety_model = car_params.getSafetyModel();
@ -197,7 +201,7 @@ void can_recv(PubMaster &pm) {
void can_send_thread(bool fake_send) {
LOGD("start send thread");
AlignedBuffer aligned_buf;
kj::Array<capnp::word> buf = kj::heapArray<capnp::word>(1024);
Context * context = Context::create();
SubSocket * subscriber = SubSocket::create(context, "sendcan");
assert(subscriber != NULL);
@ -213,8 +217,13 @@ void can_send_thread(bool fake_send) {
}
continue;
}
const size_t size = (msg->getSize() / sizeof(capnp::word)) + 1;
if (buf.size() < size) {
buf = kj::heapArray<capnp::word>(size);
}
memcpy(buf.begin(), msg->getData(), msg->getSize());
capnp::FlatArrayMessageReader cmsg(aligned_buf.get(msg));
capnp::FlatArrayMessageReader cmsg(buf.slice(0, size));
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
//Dont send if older than 1 second

@ -23,7 +23,7 @@ ExitHandler do_exit;
using namespace ublox;
int ubloxd_main(poll_ubloxraw_msg_func poll_func, send_gps_event_func send_func) {
LOGW("starting ubloxd");
AlignedBuffer aligned_buf;
kj::Array<capnp::word> buf = kj::heapArray<capnp::word>(1024);
UbloxMsgParser parser;
Context * context = Context::create();
@ -41,8 +41,13 @@ int ubloxd_main(poll_ubloxraw_msg_func poll_func, send_gps_event_func send_func)
}
continue;
}
const size_t size = (msg->getSize() / sizeof(capnp::word)) + 1;
if (buf.size() < size) {
buf = kj::heapArray<capnp::word>(size);
}
memcpy(buf.begin(), msg->getData(), msg->getSize());
capnp::FlatArrayMessageReader cmsg(aligned_buf.get(msg));
capnp::FlatArrayMessageReader cmsg(buf.slice(0, size));
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
auto ubloxRaw = event.getUbloxRaw();

@ -383,7 +383,7 @@ int main(int argc, char** argv) {
uint64_t msg_count = 0;
uint64_t bytes_count = 0;
AlignedBuffer aligned_buf;
kj::Array<capnp::word> buf = kj::heapArray<capnp::word>(1024);
double start_ts = seconds_since_boot();
double last_rotate_tms = millis_since_boot();
@ -427,7 +427,15 @@ int main(int argc, char** argv) {
if (fpkt_id >= 0) {
// track camera frames to sync to encoder
// only process last frame
capnp::FlatArrayMessageReader cmsg(aligned_buf.get(last_msg));
const uint8_t* data = (uint8_t*)last_msg->getData();
const size_t len = last_msg->getSize();
const size_t size = len / sizeof(capnp::word) + 1;
if (buf.size() < size) {
buf = kj::heapArray<capnp::word>(size);
}
memcpy(buf.begin(), data, len);
capnp::FlatArrayMessageReader cmsg(buf);
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
if (fpkt_id == LOG_CAMERA_ID_FCAMERA) {

Loading…
Cancel
Save