Compare commits
No commits in common. "b2ec530a4bdd6478c9a33922055b8cac55b302c3" and "268e4e125f6283b087205b617ee7f080181b4d94" have entirely different histories.
b2ec530a4b
...
268e4e125f
@ -108,24 +108,24 @@ void UartHandler::stop_reading()
|
||||
void UartHandler::read_loop()
|
||||
{
|
||||
uint8_t buf[512];
|
||||
// auto last_receive_time = std::chrono::steady_clock::now();
|
||||
auto last_receive_time = std::chrono::steady_clock::now();
|
||||
|
||||
while (reading)
|
||||
{
|
||||
int n = read(fd, buf, sizeof(buf));
|
||||
if (n > 0)
|
||||
{
|
||||
// last_receive_time = std::chrono::steady_clock::now();
|
||||
last_receive_time = std::chrono::steady_clock::now();
|
||||
parse_data(buf, n);
|
||||
}
|
||||
else if (n == 0 || (n < 0 && errno == EAGAIN))
|
||||
{
|
||||
// 检查超时
|
||||
// auto now = std::chrono::steady_clock::now();
|
||||
// if (std::chrono::duration_cast<std::chrono::seconds>(now - last_receive_time).count() > 2) // 超过2秒没数据
|
||||
// {
|
||||
// failsafe_status = SBUS_SIGNAL_LOST;
|
||||
// }
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
if (std::chrono::duration_cast<std::chrono::seconds>(now - last_receive_time).count() > 2) // 超过2秒没数据
|
||||
{
|
||||
failsafe_status = SBUS_SIGNAL_LOST;
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user