diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-31 17:31:58 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-31 17:31:58 +0100 |
commit | e137d004243f29520edce69c75be7abbe13fdf10 (patch) | |
tree | 87fd048d47e20e7f49f9355ea763aca764dce00f /apps/mavlink/mavlink_receiver.c | |
parent | e7bbe685b4837b5259b3e15bd24c0e6fea7bc01c (diff) | |
download | px4-firmware-e137d004243f29520edce69c75be7abbe13fdf10.tar.gz px4-firmware-e137d004243f29520edce69c75be7abbe13fdf10.tar.bz2 px4-firmware-e137d004243f29520edce69c75be7abbe13fdf10.zip |
HOTFIX: Fixed HoTT compile error, fixed MAVLink crash
Diffstat (limited to 'apps/mavlink/mavlink_receiver.c')
-rw-r--r-- | apps/mavlink/mavlink_receiver.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/mavlink/mavlink_receiver.c b/apps/mavlink/mavlink_receiver.c index 9491ce7e3..86732d07c 100644 --- a/apps/mavlink/mavlink_receiver.c +++ b/apps/mavlink/mavlink_receiver.c @@ -587,12 +587,12 @@ receive_thread(void *arg) struct pollfd fds[] = { { .fd = uart_fd, .events = POLLIN } }; if (poll(fds, 1, timeout) > 0) { - /* non-blocking read */ - size_t nread = read(uart_fd, buf, sizeof(buf)); - ASSERT(nread > 0) + /* non-blocking read. read may return negative values */ + ssize_t nread = read(uart_fd, buf, sizeof(buf)); - for (size_t i = 0; i < nread; i++) { - if (mavlink_parse_char(chan, buf[i], &msg, &status)) { //parse the char + /* if read failed, this loop won't execute */ + for (ssize_t i = 0; i < nread; i++) { + if (mavlink_parse_char(chan, buf[i], &msg, &status)) { /* handle generic messages and commands */ handle_message(&msg); |