Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Wake HW serial device up before reading #18

Draft
wants to merge 1 commit into
base: auterion-router-latest
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/mavlink-router/endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ int UartEndpoint::read_msg(struct buffer *pbuf, int *target_sysid, int *target_c

ssize_t UartEndpoint::_read_msg(uint8_t *buf, size_t len)
{
// On some hardware-serial interfaces, it is necessary to kick the device
// before reading from it, otherwise we don't get any data
struct buffer dummy{0};
ssize_t p = ::write(fd, &dummy, 1);
ssize_t r = ::read(fd, buf, len);
if ((r == -1 && errno == EAGAIN) || r == 0)
return 0;
Expand Down