Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DUMP1090_CFLAGS := -std=c11 -fno-common -Wall -Wmissing-declarations -Werror -Wf
DUMP1090_CPPFLAGS := -I. -D_POSIX_C_SOURCE=200112L -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\"

LIBS = -lpthread -lm
SDR_OBJ = cpu.o sdr.o fifo.o sdr_ifile.o dsp/helpers/tables.o
SDR_OBJ = cpu.o sdr.o fifo.o sdr_ifile.o sdr_beast.o dsp/helpers/tables.o

# Try to autodetect available libraries via pkg-config if no explicit setting was used
PKGCONFIG=$(shell pkg-config --version >/dev/null 2>&1 && echo "yes" || echo "no")
Expand Down
15 changes: 15 additions & 0 deletions dump1090.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,21 @@ int main(int argc, char **argv) {

nanosleep(&slp, NULL);
}
} else if(Modes.sdr_type == SDR_BEASTFILE) {
// Create the thread that will read the data from the device.

pthread_create(&Modes.reader_thread, NULL, readerThreadEntryPoint, NULL);

while (!Modes.exit) {
struct timespec start_time;

start_cpu_timing(&start_time);
backgroundTasks();
end_cpu_timing(&start_time, &Modes.stats_current.background_cpu);
}

log_with_timestamp("Waiting for receive thread termination");
pthread_join(Modes.reader_thread,NULL); // Wait on reader thread exit
} else {
int watchdogCounter = 300; // about 30 seconds

Expand Down
2 changes: 1 addition & 1 deletion dump1090.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ typedef enum {
//======================== structure declarations =========================

typedef enum {
SDR_NONE, SDR_IFILE, SDR_RTLSDR, SDR_BLADERF, SDR_HACKRF, SDR_LIMESDR, SDR_SOAPYSDR
SDR_NONE, SDR_IFILE, SDR_BEASTFILE, SDR_RTLSDR, SDR_BLADERF, SDR_HACKRF, SDR_LIMESDR, SDR_SOAPYSDR
} sdr_type_t;

// Program global state
Expand Down
19 changes: 11 additions & 8 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,7 @@ static void send_raw_heartbeat(struct net_service *service)
//
// Write SBS output to TCP clients
//
static void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {
char *p;
void modesPrepareSBSOutput(struct modesMessage *mm, struct aircraft *a, char *p) {
struct timespec now;
struct tm stTime_receive, stTime_now;
int msgType;
Expand All @@ -594,10 +593,6 @@ static void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {
if (mm->addr & MODES_NON_ICAO_ADDRESS)
return;

p = prepareWrite(&Modes.sbs_out, 200);
if (!p)
return;

//
// SBS BS style output checked against the following reference
// http://www.homepages.mcb.net/bones/SBS/Article/Barebones42_Socket_Data.htm - seems comprehensive
Expand Down Expand Up @@ -782,7 +777,15 @@ static void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {
}

p += sprintf(p, "\r\n");
}

static void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {

char *p;
p = prepareWrite(&Modes.sbs_out, 200);
if (!p)
return;
modesPrepareSBSOutput(mm, a, p);
completeWrite(&Modes.sbs_out, p);
}

Expand Down Expand Up @@ -1024,7 +1027,7 @@ void modesQueueOutput(struct modesMessage *mm, struct aircraft *a) {
}

// Decode a little-endian IEEE754 float (binary32)
static float ieee754_binary32_le_to_float(uint8_t *data)
float ieee754_binary32_le_to_float(uint8_t *data)
{
double sign = (data[3] & 0x80) ? -1.0 : 1.0;
int16_t raw_exponent = ((data[3] & 0x7f) << 1) | ((data[2] & 0x80) >> 7);
Expand Down Expand Up @@ -1058,7 +1061,7 @@ static float ieee754_binary32_le_to_float(uint8_t *data)
return ldexp(sign * ((1 << 23) | raw_significand), raw_exponent - 127 - 23);
}

static void handle_radarcape_position(float lat, float lon, float alt)
void handle_radarcape_position(float lat, float lon, float alt)
{
if (!isfinite(lat) || lat < -90 || lat > 90 || !isfinite(lon) || lon < -180 || lon > 180 || !isfinite(alt))
return;
Expand Down
3 changes: 3 additions & 0 deletions net_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ struct net_service *makeFaCmdInputService(void);
void sendBeastSettings(struct client *c, const char *settings);

void modesInitNet(void);
void modesPrepareSBSOutput(struct modesMessage *mm, struct aircraft *a, char *p);
void modesQueueOutput(struct modesMessage *mm, struct aircraft *a);
float ieee754_binary32_le_to_float(uint8_t *data);
void handle_radarcape_position(float lat, float lon, float alt);
void modesNetPeriodicWork(void);

// TODO: move these somewhere else
Expand Down
2 changes: 2 additions & 0 deletions sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "dump1090.h"

#include "sdr_ifile.h"
#include "sdr_beast.h"
#ifdef ENABLE_RTLSDR
# include "sdr_rtlsdr.h"
#endif
Expand Down Expand Up @@ -137,6 +138,7 @@ static sdr_handler sdr_handlers[] = {

{ "none", SDR_NONE, noInitConfig, noShowHelp, noHandleOption, noOpen, noRun, noStop, noClose, noGetGain, noGetMaxGain, noGetGainDb, noSetGain },
{ "ifile", SDR_IFILE, ifileInitConfig, ifileShowHelp, ifileHandleOption, ifileOpen, ifileRun, noStop, ifileClose, noGetGain, noGetMaxGain, noGetGainDb, noSetGain },
{ "beastfile", SDR_BEASTFILE, beastInitConfig, beastShowHelp, beastHandleOption, beastOpen, beastRun, noStop, beastClose, noGetGain, noGetMaxGain, noGetGainDb, noSetGain },

{ NULL, SDR_NONE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } /* must come last */
};
Expand Down
Loading