исправление зависания программы спустя пол часа
This commit is contained in:
10
air/main.cpp
10
air/main.cpp
@@ -12,15 +12,15 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <sys/time.h>
|
#include <time.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Вспомогательная функция для получения текущего времени в миллисекундах
|
* Вспомогательная функция для получения текущего времени в миллисекундах
|
||||||
*/
|
*/
|
||||||
inline int64_t milliseconds() {
|
inline int64_t milliseconds() {
|
||||||
timeval tv{};
|
timespec ts{};
|
||||||
gettimeofday(&tv,nullptr);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
return ((tv.tv_sec * 1000000l) + tv.tv_usec) / 1000;
|
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;
|
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) {
|
if (now - lastSbusWrite >= SBUS_SEND_FRAME_INTERVAL && now - lastSbusRecv <= SBUS_RXLOSS_INTERVAL) {
|
||||||
lastSbusWrite = now;
|
lastSbusWrite = now;
|
||||||
if (!serial.writeBuffer(sb.binaryBuffer)) {
|
if (!serial.writeBuffer(sb.binaryBuffer)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user