From c16b9f54308711612056e04eb1aa4307c8b1cf67 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Mon, 16 Sep 2024 14:25:01 +0200 Subject: [PATCH] read returning zero not an error for serial clients --- net_io.c | 10 ++++++++-- net_io.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/net_io.c b/net_io.c index 0f0d16ce..0e5da7b5 100644 --- a/net_io.c +++ b/net_io.c @@ -318,6 +318,7 @@ static struct client *createSocketClient(struct net_service *service, int fd) { if ((c->fd == Modes.beast_fd) && (Modes.sdr_type == SDR_MODESBEAST || Modes.sdr_type == SDR_GNS)) { /* Message from a local connected Modes-S beast or GNS5894 are passed off the internet */ c->remote = 0; + c->serial = 1; } //fprintf(stderr, "c->receiverId: %016"PRIx64"\n", c->receiverId); @@ -4459,7 +4460,7 @@ static int readClient(struct client *c, int64_t now) { return 0; } // Other errors - if (!c->remote) { + if (c->serial) { fprintf(stderr, "Serial client read error: %s\n", strerror(err)); } if (Modes.debug_net) { @@ -4473,6 +4474,11 @@ static int readClient(struct client *c, int64_t now) { // End of file if (nread == 0) { + if (c->serial) { + // for serial this just means we're doing non-blocking reads and there are no bytes available + return 0; + } + if (c->con) { if (Modes.synthetic_now) { Modes.synthetic_now = 0; @@ -5399,7 +5405,7 @@ void modesNetPeriodicWork(void) { int64_t wait_ms; if (Modes.sdr_type == SDR_MODESBEAST || Modes.sdr_type == SDR_GNS) { - wait_ms = 20; + wait_ms = 100; } else if (Modes.sdr_type != SDR_NONE) { // NO WAIT WHEN USING AN SDR !! IMPORTANT !! wait_ms = 0; diff --git a/net_io.h b/net_io.h index 344f1bad..7eb5e92f 100644 --- a/net_io.h +++ b/net_io.h @@ -100,6 +100,7 @@ struct client int fd; // File descriptor int8_t bufferToProcess; int8_t remote; + int8_t serial; int8_t bContinue; int8_t discard; int8_t processing;