Skip to content

Commit

Permalink
Merged
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzMeier committed Sep 20, 2015
1 parent d2459a1 commit 985243c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/modules/simulator/simulator_mavlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,15 @@ void Simulator::pollForMAVLinkMessages(bool publish)
char serial_buf[1024];

struct pollfd fds[2];
unsigned fd_count = 1;
fds[0].fd = _fd;
fds[0].events = POLLIN;
fds[1].fd = serial_fd;
fds[1].events = POLLIN;

if (serial_fd >= 0) {
fds[1].fd = serial_fd;
fds[1].events = POLLIN;
fd_count++;
}

int len = 0;

Expand Down Expand Up @@ -496,7 +501,7 @@ void Simulator::pollForMAVLinkMessages(bool publish)
// wait for new mavlink messages to arrive
while (true) {

pret = ::poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 100);
pret = ::poll(&fds[0], fd_count, 100);

//timed out
if (pret == 0) {
Expand Down

0 comments on commit 985243c

Please sign in to comment.