Skip to content

Commit

Permalink
better serial debugging timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 16, 2024
1 parent 4de46de commit 8642e5f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4433,13 +4433,13 @@ static int readClient(struct client *c, int64_t now) {
nread = recv(c->fd, c->buf + c->buflen, left, 0);
} else {
// read instead of recv for modesbeast / gns-hulc ....
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
if (0 && Modes.debug_serial) {
fprintTimePrecise(stderr, mstime());
fprintf(stderr, " serial read ... fd: %d maxbytes: %d\n", c->fd, left);
}
nread = read(c->fd, c->buf + c->buflen, left);
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
if (nread > -1 && Modes.debug_serial) {
fprintTimePrecise(stderr, mstime());
fprintf(stderr, " serial read return value: %d\n", nread);
}
}
Expand All @@ -4459,6 +4459,9 @@ static int readClient(struct client *c, int64_t now) {
return 0;
}
// Other errors
if (!c->remote) {
fprintf(stderr, "Serial client read error: %s\n", strerror(err));
}
if (Modes.debug_net) {
fprintf(stderr, "%s: Socket Error: %s: %s port %s (fd %d, SendQ %d, RecvQ %d)\n",
c->service->descr, strerror(err), c->host, c->port,
Expand Down Expand Up @@ -5395,7 +5398,7 @@ void modesNetPeriodicWork(void) {
dump_beast_check(now);

int64_t wait_ms;
if (Modes.serial_client) {
if (Modes.sdr_type == SDR_MODESBEAST || Modes.sdr_type == SDR_GNS) {
wait_ms = 20;
} else if (Modes.sdr_type != SDR_NONE) {
// NO WAIT WHEN USING AN SDR !! IMPORTANT !!
Expand All @@ -5419,8 +5422,8 @@ void modesNetPeriodicWork(void) {
Modes.services_in.event_progress = 0;
Modes.services_out.event_progress = 0;

if (Modes.debug_serial) {
fprintTimePrecise(stderr, now); fprintf(stderr, " event count %d wait_ms %d\n", Modes.net_event_count, (int) wait_ms);
if (Modes.debug_serial && Modes.net_event_count > 0) {
fprintTimePrecise(stderr, mstime()); fprintf(stderr, " event count %d wait_ms %d\n", Modes.net_event_count, (int) wait_ms);
}

if (0 && Modes.net_event_count > 0) {
Expand Down Expand Up @@ -5465,18 +5468,19 @@ void modesNetPeriodicWork(void) {
if (Modes.sdrInitialized && (Modes.sdr_type == SDR_MODESBEAST || Modes.sdr_type == SDR_GNS)) {
if (!Modes.serial_client) {
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
fprintTimePrecise(stderr, mstime());
fprintf(stderr, " serial: creating socket client ... \n");
}
Modes.serial_client = createSocketClient(Modes.beast_in_service, Modes.beast_fd);
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
fprintTimePrecise(stderr, mstime());
fprintf(stderr, " serial: creating socket client ... done\n");
}
}
if (Modes.serial_client->service) {
modesReadFromClient(Modes.serial_client, mb);
} else {
}
if (!Modes.serial_client->service) {
fprintf(stderr, "Serial client closed unexpectedly, exiting!\n");
setExit(2);
}
Expand Down

0 comments on commit 8642e5f

Please sign in to comment.