исправление зависания программы спустя пол часа
This commit is contained in:
10
air/main.cpp
10
air/main.cpp
@@ -12,15 +12,15 @@
|
||||
#include <cstring>
|
||||
#include <atomic>
|
||||
#include <span>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
/**
|
||||
* Вспомогательная функция для получения текущего времени в миллисекундах
|
||||
*/
|
||||
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<int64_t>(ts.tv_sec) * 1000 + static_cast<int64_t>(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)) {
|
||||
|
||||
Reference in New Issue
Block a user