Skip to content

Commit

Permalink
read returning zero not an error for serial clients
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 16, 2024
1 parent 50cc9de commit c16b9f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions net_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c16b9f5

Please sign in to comment.