Exemplo n.º 1
0
 virtual void adjustUtc(uavcan::UtcDuration adjustment)
 {
     assert(this);
     const uint64_t prev_utc = utc;
     utc = uint64_t(int64_t(utc) + adjustment.toUSec());
     last_adjustment = adjustment;
     std::cout << "Clock adjustment " << prev_utc << " --> " << utc << std::endl;
 }
Exemplo n.º 2
0
 bool performGradualAdjustment(const uavcan::UtcDuration adjustment)
 {
     gradual_adj_cnt_++;
     const std::int64_t usec = adjustment.toUSec();
     timeval tv;
     tv.tv_sec  = usec / Int1e6;
     tv.tv_usec = usec % Int1e6;
     return adjtime(&tv, nullptr) == 0;
 }
Exemplo n.º 3
0
 bool performStepAdjustment(const uavcan::UtcDuration adjustment)
 {
     step_adj_cnt_++;
     const std::int64_t usec = adjustment.toUSec();
     timeval tv;
     if (gettimeofday(&tv, NULL) != 0)
     {
         return false;
     }
     tv.tv_sec  += usec / Int1e6;
     tv.tv_usec += usec % Int1e6;
     return settimeofday(&tv, nullptr) == 0;
 }