Skip to content

Commit a3930f4

Browse files
committed
Flag for system timestamp in Beast output
Allow the user to specify that the system timestamp should be used in the Beast output timestamp bytes instead of the device-specific timestamp.
1 parent 849a3b7 commit a3930f4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

dump1090.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ static void showHelp(void)
403403
"--net-buffer <n> TCP buffer size 64Kb * (2^n) (default: n=0, 64Kb)\n"
404404
"--net-verbatim Make output connections default to verbatim mode\n"
405405
" (forward all messages without correction)\n"
406+
"--beast-sys-time Encode the system timestamp in Beast output\n"
406407
"--forward-mlat Allow forwarding of received mlat results\n"
407408
"\n"
408409
// ------ 80 char limit ----------------------------------------------------------|
@@ -693,6 +694,8 @@ int main(int argc, char **argv) {
693694
Modes.net_sndbuf_size = atoi(argv[++j]);
694695
} else if (!strcmp(argv[j],"--net-verbatim")) {
695696
Modes.net_verbatim = 1;
697+
} else if (!strcmp(argv[j],"--beast-sys-time")) {
698+
Modes.beast_sys_timestamp = 1;
696699
} else if (!strcmp(argv[j],"--forward-mlat")) {
697700
Modes.forward_mlat = 1;
698701
} else if (!strcmp(argv[j],"--onlyaddr")) {

dump1090.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ struct _Modes { // Internal state
365365
char *net_bind_address; // Bind address
366366
int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n)
367367
int net_verbatim; // if true, Beast output connections default to verbatim mode
368+
int beast_sys_timestamp; // if true, use the system timestamp for Beast output
368369
int forward_mlat; // allow forwarding of mlat messages to output ports
369370
int quiet; // Suppress stdout
370371
uint32_t show_only; // Only show messages from this ICAO

net_io.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,16 @@ static void completeWrite(struct net_writer *writer, void *endptr) {
399399
//
400400
// Write raw output in Beast Binary format with Timestamp to TCP clients
401401
//
402+
403+
#define BEAST_TIMESTAMP Modes.beast_sys_timestamp ? mm->sysTimestampMsg : mm->timestampMsg
404+
402405
static void modesSendBeastVerbatimOutput(struct modesMessage *mm, struct aircraft __attribute__((unused)) *a) {
403406
// Don't forward mlat messages, unless --forward-mlat is set
404407
if (mm->source == SOURCE_MLAT && !Modes.forward_mlat)
405408
return;
406409

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

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

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

431+
#undef BEAST_TIMESTAMP
432+
428433
static void writeBeastMessage(struct net_writer *writer, uint64_t timestamp, double signalLevel, unsigned char *msg, int msgLen) {
429434
char ch;
430435
int j;

0 commit comments

Comments
 (0)