Skip to content

Commit

Permalink
fixup modesbeast startup race
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 16, 2024
1 parent 0b342c0 commit 2a5e8b9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,6 @@ void modesInitNet(void) {
}
serviceListen(Modes.beast_in_service, Modes.net_bind_address, Modes.net_input_beast_ports, Modes.net_epfd);

/* Beast input from local Modes-S Beast via USB */
if (Modes.sdr_type == SDR_MODESBEAST || Modes.sdr_type == SDR_GNS) {
Modes.serial_client = createSocketClient(Modes.beast_in_service, Modes.beast_fd);
}

/* Planefinder input via network */
planefinder_in = serviceInit(&Modes.services_in, "Planefinder TCP input", NULL, no_heartbeat, no_heartbeat, READ_MODE_PLANEFINDER, NULL, decodePfMessage);
serviceListen(planefinder_in, Modes.net_bind_address, Modes.net_input_planefinder_ports, Modes.net_epfd);
Expand Down Expand Up @@ -5466,7 +5461,19 @@ void modesNetPeriodicWork(void) {
timespec_add_elapsed(&before, &after, &Modes.stats_current.background_cpu);
}

if (Modes.serial_client) {
/* Beast input from local Modes-S Beast via USB */
if (Modes.sdrInitialized && (Modes.sdr_type == SDR_MODESBEAST || Modes.sdr_type == SDR_GNS)) {
if (!Modes.serial_client) {
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
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);
fprintf(stderr, " serial: creating socket client ... done\n");
}
}
if (Modes.serial_client->service) {
modesReadFromClient(Modes.serial_client, mb);
} else {
Expand Down

0 comments on commit 2a5e8b9

Please sign in to comment.