cereal: use nanos_since_boot() from common/timing.h (#32840)

Use nanos_since_boot() from common/timing.h
old-commit-hash: fccba867a9
fix-exp-path
Dean Lee 10 months ago committed by GitHub
parent f0fdff113d
commit b07f5254ef
  1. 14
      cereal/messaging/messaging.h
  2. 8
      cereal/messaging/socketmaster.cc

@ -5,20 +5,13 @@
#include <string>
#include <vector>
#include <utility>
#include <time.h>
#include <capnp/serialize.h>
#include "cereal/gen/cpp/log.capnp.h"
#include "common/timing.h"
#include "msgq/ipc.h"
#ifdef __APPLE__
#define CLOCK_BOOTTIME CLOCK_MONOTONIC
#endif
#define MSG_MULTIPLE_PUBLISHERS 100
class SubMaster {
public:
SubMaster(const std::vector<const char *> &service_list, const std::vector<const char *> &poll = {},
@ -53,10 +46,7 @@ public:
cereal::Event::Builder initEvent(bool valid = true) {
cereal::Event::Builder event = initRoot<cereal::Event>();
struct timespec t;
clock_gettime(CLOCK_BOOTTIME, &t);
uint64_t current_time = t.tv_sec * 1000000000ULL + t.tv_nsec;
event.setLogMonoTime(current_time);
event.setLogMonoTime(nanos_since_boot());
event.setValid(valid);
return event;
}

@ -1,4 +1,3 @@
#include <time.h>
#include <assert.h>
#include <stdlib.h>
#include <string>
@ -7,15 +6,8 @@
#include "cereal/services.h"
#include "cereal/messaging/messaging.h"
const bool SIMULATION = (getenv("SIMULATION") != nullptr) && (std::string(getenv("SIMULATION")) == "1");
static inline uint64_t nanos_since_boot() {
struct timespec t;
clock_gettime(CLOCK_BOOTTIME, &t);
return t.tv_sec * 1000000000ULL + t.tv_nsec;
}
static inline bool inList(const std::vector<const char *> &list, const char *value) {
for (auto &v : list) {
if (strcmp(value, v) == 0) return true;

Loading…
Cancel
Save