diff --git a/air/main.cpp b/air/main.cpp index 59b74cd..caefbaf 100644 --- a/air/main.cpp +++ b/air/main.cpp @@ -12,15 +12,15 @@ #include #include #include -#include +#include /** * Вспомогательная функция для получения текущего времени в миллисекундах */ inline int64_t milliseconds() { - timeval tv{}; - gettimeofday(&tv,nullptr); - return ((tv.tv_sec * 1000000l) + tv.tv_usec) / 1000; + timespec ts{}; + clock_gettime(CLOCK_MONOTONIC, &ts); + return static_cast(ts.tv_sec) * 1000 + static_cast(ts.tv_nsec) / 1000000; } constexpr int64_t SBUS_SEND_FRAME_INTERVAL = 50; @@ -329,7 +329,7 @@ int main(int argc, char* argv[]) { } } - std::cout << "from loop: current time " << now << std::endl; + // std::cout << "from loop: current time " << now << std::endl; if (now - lastSbusWrite >= SBUS_SEND_FRAME_INTERVAL && now - lastSbusRecv <= SBUS_RXLOSS_INTERVAL) { lastSbusWrite = now; if (!serial.writeBuffer(sb.binaryBuffer)) {