use class AlignedBuffer from cereal (#20343)

* AlignedBuffer

* move AlignedBuffer to cereal/messaging.hpp

* rename function aligned to get

* use overloaded function AlignedBuffer:: get(Message *)
old-commit-hash: 7aa379e123aba70a4c36f95e69786a558892dc2d
This commit is contained in:
Dean Lee
2021-03-16 18:13:15 +08:00
committed by GitHub
parent b8925e456a
commit 4c02da3f0a
3 changed files with 7 additions and 29 deletions
+2 -7
View File
@@ -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");
kj::Array<capnp::word> buf = kj::heapArray<capnp::word>(1024);
AlignedBuffer aligned_buf;
UbloxMsgParser parser;
Context * context = Context::create();
@@ -41,13 +41,8 @@ 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(buf.slice(0, size));
capnp::FlatArrayMessageReader cmsg(aligned_buf.get(msg));
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
auto ubloxRaw = event.getUbloxRaw();