create library for using locationd in python using ffi (#20711)
* create library for using locationd in python using ffi
* lib is not required in release
* cleanup
* dont build liblocationd on release
* add check on buffer size
old-commit-hash: e08a570a13
commatwo_master
parent
2803d26b14
commit
e07740c35c
2 changed files with 29 additions and 3 deletions
@ -0,0 +1,22 @@ |
||||
#include "locationd.h" |
||||
|
||||
extern "C" { |
||||
typedef Localizer* Localizer_t; |
||||
|
||||
Localizer *localizer_init() { |
||||
return new Localizer(); |
||||
} |
||||
|
||||
void localizer_get_message_bytes(Localizer *localizer, uint64_t logMonoTime, |
||||
bool inputsOK, bool sensorsOK, bool gpsOK, char *buff, size_t buff_size) |
||||
{ |
||||
MessageBuilder msg_builder; |
||||
kj::ArrayPtr<char> arr = localizer->get_message_bytes(msg_builder, logMonoTime, inputsOK, sensorsOK, gpsOK).asChars(); |
||||
assert(buff_size >= arr.size()); |
||||
memcpy(buff, arr.begin(), arr.size()); |
||||
} |
||||
|
||||
void localizer_handle_msg_bytes(Localizer *localizer, const char *data, size_t size) { |
||||
localizer->handle_msg_bytes(data, size); |
||||
} |
||||
} |
Loading…
Reference in new issue