Skip to content

Commit

Permalink
Flag for system timestamp in Beast output
Browse files Browse the repository at this point in the history
Allow the user to specify that the system timestamp should be used in
the Beast output timestamp bytes instead of the device-specific
timestamp.
  • Loading branch information
xander-hirsch committed Aug 5, 2022
1 parent 849a3b7 commit a3930f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions dump1090.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ static void showHelp(void)
"--net-buffer <n> TCP buffer size 64Kb * (2^n) (default: n=0, 64Kb)\n"
"--net-verbatim Make output connections default to verbatim mode\n"
" (forward all messages without correction)\n"
"--beast-sys-time Encode the system timestamp in Beast output\n"
"--forward-mlat Allow forwarding of received mlat results\n"
"\n"
// ------ 80 char limit ----------------------------------------------------------|
Expand Down Expand Up @@ -693,6 +694,8 @@ int main(int argc, char **argv) {
Modes.net_sndbuf_size = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--net-verbatim")) {
Modes.net_verbatim = 1;
} else if (!strcmp(argv[j],"--beast-sys-time")) {
Modes.beast_sys_timestamp = 1;
} else if (!strcmp(argv[j],"--forward-mlat")) {
Modes.forward_mlat = 1;
} else if (!strcmp(argv[j],"--onlyaddr")) {
Expand Down
1 change: 1 addition & 0 deletions dump1090.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ struct _Modes { // Internal state
char *net_bind_address; // Bind address
int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n)
int net_verbatim; // if true, Beast output connections default to verbatim mode
int beast_sys_timestamp; // if true, use the system timestamp for Beast output
int forward_mlat; // allow forwarding of mlat messages to output ports
int quiet; // Suppress stdout
uint32_t show_only; // Only show messages from this ICAO
Expand Down
9 changes: 7 additions & 2 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,16 @@ static void completeWrite(struct net_writer *writer, void *endptr) {
//
// Write raw output in Beast Binary format with Timestamp to TCP clients
//

#define BEAST_TIMESTAMP Modes.beast_sys_timestamp ? mm->sysTimestampMsg : mm->timestampMsg

static void modesSendBeastVerbatimOutput(struct modesMessage *mm, struct aircraft __attribute__((unused)) *a) {
// Don't forward mlat messages, unless --forward-mlat is set
if (mm->source == SOURCE_MLAT && !Modes.forward_mlat)
return;

// Do verbatim output for all messages
writeBeastMessage(&Modes.beast_verbatim_out, mm->timestampMsg, mm->signalLevel, mm->verbatim, mm->msgbits / 8);
writeBeastMessage(&Modes.beast_verbatim_out, BEAST_TIMESTAMP, mm->signalLevel, mm->verbatim, mm->msgbits / 8);
}

static void modesSendBeastCookedOutput(struct modesMessage *mm, struct aircraft *a) {
Expand All @@ -422,9 +425,11 @@ static void modesSendBeastCookedOutput(struct modesMessage *mm, struct aircraft
if ((a && !a->reliable) && !mm->reliable)
return;

writeBeastMessage(&Modes.beast_cooked_out, mm->timestampMsg, mm->signalLevel, mm->msg, mm->msgbits / 8);
writeBeastMessage(&Modes.beast_cooked_out, BEAST_TIMESTAMP, mm->signalLevel, mm->msg, mm->msgbits / 8);
}

#undef BEAST_TIMESTAMP

static void writeBeastMessage(struct net_writer *writer, uint64_t timestamp, double signalLevel, unsigned char *msg, int msgLen) {
char ch;
int j;
Expand Down

0 comments on commit a3930f4

Please sign in to comment.