small ubloxd cleanup

pull/19546/head
Adeeb Shihadeh 5 years ago
parent 3bf43bd7e3
commit c131f9db57
  1. 1
      release/files_common
  2. 13
      selfdrive/locationd/SConscript
  3. 17
      selfdrive/locationd/ublox_msg.cc
  4. 1
      selfdrive/locationd/ublox_msg.h
  5. 23
      selfdrive/locationd/ubloxd.cc
  6. 1
      selfdrive/locationd/ubloxd_main.cc
  7. 16
      selfdrive/locationd/ubloxd_test.cc

@ -286,7 +286,6 @@ selfdrive/locationd/.gitignore
selfdrive/locationd/SConscript selfdrive/locationd/SConscript
selfdrive/locationd/ubloxd.cc selfdrive/locationd/ubloxd.cc
selfdrive/locationd/ubloxd_main.cc selfdrive/locationd/ubloxd_main.cc
selfdrive/locationd/ubloxd_test.cc
selfdrive/locationd/ublox_msg.cc selfdrive/locationd/ublox_msg.cc
selfdrive/locationd/ublox_msg.h selfdrive/locationd/ublox_msg.h

@ -2,14 +2,7 @@ Import('env', 'common', 'cereal', 'messaging')
loc_libs = [cereal, messaging, 'zmq', common, 'capnp', 'kj', 'pthread'] loc_libs = [cereal, messaging, 'zmq', common, 'capnp', 'kj', 'pthread']
env.Program("ubloxd", [ env.Program("ubloxd", ["ubloxd.cc", "ublox_msg.cc", "ubloxd_main.cc"], LIBS=loc_libs)
"ubloxd.cc",
"ublox_msg.cc",
"ubloxd_main.cc"],
LIBS=loc_libs)
env.Program("ubloxd_test", [ if GetOption("test"):
"ubloxd_test.cc", env.Program("ubloxd_test", ["ubloxd_test.cc", "ublox_msg.cc", "ubloxd_main.cc"], LIBS=loc_libs)
"ublox_msg.cc",
"ubloxd_main.cc"],
LIBS=loc_libs)

@ -1,20 +1,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <sched.h>
#include <sys/time.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <math.h> #include <math.h>
#include <ctime> #include <ctime>
#include <chrono> #include <chrono>
#include <algorithm>
#include "common/params.h"
#include "common/swaglog.h" #include "common/swaglog.h"
#include "common/timing.h"
#include "ublox_msg.h" #include "ublox_msg.h"
@ -173,8 +164,7 @@ inline bool UbloxMsgParser::valid_cheksum() {
inline bool UbloxMsgParser::valid() { inline bool UbloxMsgParser::valid() {
return bytes_in_parse_buf >= UBLOX_HEADER_SIZE + UBLOX_CHECKSUM_SIZE && return bytes_in_parse_buf >= UBLOX_HEADER_SIZE + UBLOX_CHECKSUM_SIZE &&
needed_bytes() == 0 && needed_bytes() == 0 && valid_cheksum();
valid_cheksum();
} }
inline bool UbloxMsgParser::valid_so_far() { inline bool UbloxMsgParser::valid_so_far() {
@ -186,8 +176,9 @@ inline bool UbloxMsgParser::valid_so_far() {
//LOGD("PREAMBLE2 invalid, %02X.", msg_parse_buf[1]); //LOGD("PREAMBLE2 invalid, %02X.", msg_parse_buf[1]);
return false; return false;
} }
if(needed_bytes() == 0 && !valid()) if(needed_bytes() == 0 && !valid()) {
return false; return false;
}
return true; return true;
} }
@ -221,7 +212,7 @@ kj::Array<capnp::word> UbloxMsgParser::gen_solution() {
} }
inline bool bit_to_bool(uint8_t val, int shifts) { inline bool bit_to_bool(uint8_t val, int shifts) {
return (val & (1 << shifts)) ? true : false; return (bool)(val & (1 << shifts));
} }
kj::Array<capnp::word> UbloxMsgParser::gen_raw() { kj::Array<capnp::word> UbloxMsgParser::gen_raw() {

@ -68,6 +68,7 @@ typedef struct __attribute__((packed)) {
int8_t trkStat; int8_t trkStat;
int8_t reserved3; int8_t reserved3;
} rxm_raw_msg_extra; } rxm_raw_msg_extra;
// RXM_SFRBX // RXM_SFRBX
typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
int8_t gnssId; int8_t gnssId;

@ -1,29 +1,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sched.h>
#include <sys/time.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <math.h>
#include <ctime>
#include <chrono>
#include "messaging.hpp" #include "messaging.hpp"
#include "common/params.h"
#include "common/swaglog.h"
#include "common/timing.h"
#include "ublox_msg.h" #include "ublox_msg.h"
const long ZMQ_POLL_TIMEOUT = 1000; // In miliseconds
Message * poll_ubloxraw_msg(Poller * poller) { Message * poll_ubloxraw_msg(Poller * poller) {
auto p = poller->poll(ZMQ_POLL_TIMEOUT); auto p = poller->poll(1000);
if (p.size()) { if (p.size()) {
return p[0]->receive(); return p[0]->receive();
@ -32,11 +14,10 @@ Message * poll_ubloxraw_msg(Poller * poller) {
} }
} }
int send_gps_event(PubSocket *s, const void *buf, size_t len) { int send_gps_event(PubSocket *s, const void *buf, size_t len) {
return s->send((char*)buf, len); return s->send((char*)buf, len);
} }
int main() { int main() {
return ubloxd_main(poll_ubloxraw_msg, send_gps_event); return ubloxd_main(poll_ubloxraw_msg, send_gps_event);
} }

@ -3,7 +3,6 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <sched.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>

@ -1,16 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sched.h>
#include <sys/time.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <math.h>
#include <ctime>
#include <chrono>
#include <iostream> #include <iostream>
#include "messaging.hpp" #include "messaging.hpp"
@ -75,19 +63,23 @@ int main(int argc, char** argv) {
printf("Format: ubloxd_test stream_file_path save_prefix\n"); printf("Format: ubloxd_test stream_file_path save_prefix\n");
return 0; return 0;
} }
// Parse 11360 msgs, generate 9452 events // Parse 11360 msgs, generate 9452 events
data = (uint8_t *)read_file(argv[1], &len); data = (uint8_t *)read_file(argv[1], &len);
if(data == NULL) { if(data == NULL) {
LOGE("Read file %s failed\n", argv[1]); LOGE("Read file %s failed\n", argv[1]);
return -1; return -1;
} }
prefix = argv[2]; prefix = argv[2];
ubloxd_main(poll_ubloxraw_msg, send_gps_event); ubloxd_main(poll_ubloxraw_msg, send_gps_event);
free(data); free(data);
printf("Generated %d cereal events\n", save_idx); printf("Generated %d cereal events\n", save_idx);
if(save_idx != 9452) { if(save_idx != 9452) {
printf("Event count error: %d\n", save_idx); printf("Event count error: %d\n", save_idx);
return -1; return -1;
} }
return 0; return 0;
} }

Loading…
Cancel
Save