Skip to content

Commit

Permalink
Fix message filtering when timing out
Browse files Browse the repository at this point in the history
  • Loading branch information
berarma committed Sep 10, 2018
1 parent f34406d commit 36ffbf2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "sud.hpp"
#include "io.hpp"

#define TIMEOUT 5
#define TIMEOUT 30

SudData *readData(SudController *sud, unsigned char mode, unsigned char type) {
SudData *data;
Expand All @@ -34,6 +34,10 @@ SudData *readData(SudController *sud, unsigned char mode, unsigned char type) {
gettimeofday(&t1, NULL);
} while ((t1.tv_sec - t0.tv_sec) < TIMEOUT && (data == NULL || data->mode != mode || data->type != type));

if (data != NULL && (data->mode != mode || data->type != type)) {
data = NULL;
}

return data;
}

Expand Down

0 comments on commit 36ffbf2

Please sign in to comment.