Skip to content

Commit

Permalink
serial_debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 15, 2024
1 parent 6035235 commit e6c2edb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4439,6 +4439,10 @@ static int readClient(struct client *c, int64_t now) {
} else {
// read instead of recv for modesbeast / gns-hulc ....
nread = read(c->fd, c->buf + c->buflen, left);
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
fprintf(stderr, " serial read return value: %d\n", nread);
}
}
int err = errno;

Expand Down Expand Up @@ -5416,7 +5420,9 @@ void modesNetPeriodicWork(void) {
Modes.services_in.event_progress = 0;
Modes.services_out.event_progress = 0;

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

if (0 && Modes.net_event_count > 0) {
fprintTimePrecise(stderr, now); fprintf(stderr, " event count %d wait_ms %d\n", Modes.net_event_count, (int) wait_ms);
Expand Down
3 changes: 3 additions & 0 deletions readsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
if (strcasecmp(token[0], "debugGPS") == 0) {
Modes.debug_gps = 1;
}
if (strcasecmp(token[0], "debugSerial") == 0) {
Modes.debug_serial = 1;
}
if (strcasecmp(token[0], "debugZstd") == 0) {
Modes.debug_zstd = 1;
}
Expand Down
1 change: 1 addition & 0 deletions readsb.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ struct _Modes
int8_t mode_ac; // Enable decoding of SSR Modes A & C
int8_t mode_ac_auto; // allow toggling of A/C by Beast commands
int8_t debug_net;
int8_t debug_serial;
int8_t debug_flush;
int8_t debug_no_discard;
int8_t debug_nextra;
Expand Down
6 changes: 5 additions & 1 deletion sdr_beast.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ bool beastOpen(void) {
struct termios tios;
speed_t baud = B3000000;

Modes.beast_fd = open(Modes.beast_serial, O_RDWR | O_NOCTTY);
int flags = O_RDWR | O_NOCTTY;
if (Modes.debug_serial) {
flags |= O_NONBLOCK;
}
Modes.beast_fd = open(Modes.beast_serial, flags);
if (Modes.beast_fd < 0) {
fprintf(stderr, "Failed to open serial device %s: %s\n",
Modes.beast_serial, strerror(errno));
Expand Down

0 comments on commit e6c2edb

Please sign in to comment.