Compare commits
3 Commits
268e4e125f
...
b2ec530a4b
| Author | SHA1 | Date | |
|---|---|---|---|
| b2ec530a4b | |||
| 8654831d4c | |||
| 7688e9f3f5 |
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user