Compare commits

..

No commits in common. "b2ec530a4bdd6478c9a33922055b8cac55b302c3" and "268e4e125f6283b087205b617ee7f080181b4d94" have entirely different histories.

View File

@ -108,24 +108,24 @@ void UartHandler::stop_reading()
void UartHandler::read_loop() void UartHandler::read_loop()
{ {
uint8_t buf[512]; uint8_t buf[512];
// auto last_receive_time = std::chrono::steady_clock::now(); auto last_receive_time = std::chrono::steady_clock::now();
while (reading) while (reading)
{ {
int n = read(fd, buf, sizeof(buf)); int n = read(fd, buf, sizeof(buf));
if (n > 0) if (n > 0)
{ {
// last_receive_time = std::chrono::steady_clock::now(); last_receive_time = std::chrono::steady_clock::now();
parse_data(buf, n); parse_data(buf, n);
} }
else if (n == 0 || (n < 0 && errno == EAGAIN)) else if (n == 0 || (n < 0 && errno == EAGAIN))
{ {
// 检查超时 // 检查超时
// auto now = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now();
// if (std::chrono::duration_cast<std::chrono::seconds>(now - last_receive_time).count() > 2) // 超过2秒没数据 if (std::chrono::duration_cast<std::chrono::seconds>(now - last_receive_time).count() > 2) // 超过2秒没数据
// { {
// failsafe_status = SBUS_SIGNAL_LOST; failsafe_status = SBUS_SIGNAL_LOST;
// } }
usleep(1000); usleep(1000);
} }
else else