faup1090: write _v on every line, bump TSV_VERSION

This commit is contained in:
Oliver Jowett 2019-03-19 18:10:38 +00:00
parent 14c458db8c
commit 45886edc40
3 changed files with 4 additions and 23 deletions

View file

@ -204,7 +204,6 @@ int main(int argc, char **argv) {
// Set up output connection on stdout // Set up output connection on stdout
fatsv_output = makeFatsvOutputService(); fatsv_output = makeFatsvOutputService();
createGenericClient(fatsv_output, STDOUT_FILENO); createGenericClient(fatsv_output, STDOUT_FILENO);
writeFATSVHeader();
// Run it until we've lost either connection // Run it until we've lost either connection
while (!Modes.exit && beast_input->connections && fatsv_output->connections) { while (!Modes.exit && beast_input->connections && fatsv_output->connections) {

View file

@ -1863,26 +1863,7 @@ __attribute__ ((format (printf,4,5))) static char *appendFATSV(char *p, char *en
} }
#define TSV_MAX_PACKET_SIZE 600 #define TSV_MAX_PACKET_SIZE 600
#define TSV_VERSION 3 #define TSV_VERSION "4E"
void writeFATSVHeader()
{
char *p = prepareWrite(&Modes.fatsv_out, TSV_MAX_PACKET_SIZE);
if (!p)
return;
char *end = p + TSV_MAX_PACKET_SIZE;
p = appendFATSV(p, end, "clock", "%" PRIu64, mstime() / 1000);
p = appendFATSV(p, end, "tsv_version", "%u", TSV_VERSION);
--p; // remove last tab
p = safe_snprintf(p, end, "\n");
if (p <= end)
completeWrite(&Modes.fatsv_out, p);
else
fprintf(stderr, "fatsv: output too large (max %d, overran by %d)\n", TSV_MAX_PACKET_SIZE, (int) (p - end));
}
static void writeFATSVPositionUpdate(float lat, float lon, float alt) static void writeFATSVPositionUpdate(float lat, float lon, float alt)
{ {
@ -1901,6 +1882,7 @@ static void writeFATSVPositionUpdate(float lat, float lon, float alt)
char *end = p + TSV_MAX_PACKET_SIZE; char *end = p + TSV_MAX_PACKET_SIZE;
p = appendFATSV(p, end, "_v", "%s", TSV_VERSION);
p = appendFATSV(p, end, "clock", "%" PRIu64, messageNow() / 1000); p = appendFATSV(p, end, "clock", "%" PRIu64, messageNow() / 1000);
p = appendFATSV(p, end, "type", "%s", "location_update"); p = appendFATSV(p, end, "type", "%s", "location_update");
p = appendFATSV(p, end, "lat", "%.5f", lat); p = appendFATSV(p, end, "lat", "%.5f", lat);
@ -1924,6 +1906,7 @@ static void writeFATSVEventMessage(struct modesMessage *mm, const char *datafiel
char *end = p + TSV_MAX_PACKET_SIZE; char *end = p + TSV_MAX_PACKET_SIZE;
p = appendFATSV(p, end, "_v", "%s", TSV_VERSION);
p = appendFATSV(p, end, "clock", "%" PRIu64, messageNow() / 1000); p = appendFATSV(p, end, "clock", "%" PRIu64, messageNow() / 1000);
p = appendFATSV(p, end, (mm->addr & MODES_NON_ICAO_ADDRESS) ? "otherid" : "hexid", "%06X", mm->addr & 0xFFFFFF); p = appendFATSV(p, end, (mm->addr & MODES_NON_ICAO_ADDRESS) ? "otherid" : "hexid", "%06X", mm->addr & 0xFFFFFF);
if (mm->addrtype != ADDR_ADSB_ICAO) { if (mm->addrtype != ADDR_ADSB_ICAO) {
@ -2174,6 +2157,7 @@ static void writeFATSV()
return; return;
char *end = p + TSV_MAX_PACKET_SIZE; char *end = p + TSV_MAX_PACKET_SIZE;
p = appendFATSV(p, end, "_v", "%s", TSV_VERSION);
p = appendFATSV(p, end, "clock", "%" PRIu64, messageNow() / 1000); p = appendFATSV(p, end, "clock", "%" PRIu64, messageNow() / 1000);
p = appendFATSV(p, end, (a->addr & MODES_NON_ICAO_ADDRESS) ? "otherid" : "hexid", "%06X", a->addr & 0xFFFFFF); p = appendFATSV(p, end, (a->addr & MODES_NON_ICAO_ADDRESS) ? "otherid" : "hexid", "%06X", a->addr & 0xFFFFFF);

View file

@ -87,8 +87,6 @@ void modesInitNet(void);
void modesQueueOutput(struct modesMessage *mm, struct aircraft *a); void modesQueueOutput(struct modesMessage *mm, struct aircraft *a);
void modesNetPeriodicWork(void); void modesNetPeriodicWork(void);
void writeFATSVHeader();
// TODO: move these somewhere else // TODO: move these somewhere else
char *generateAircraftJson(const char *url_path, int *len); char *generateAircraftJson(const char *url_path, int *len);
char *generateStatsJson(const char *url_path, int *len); char *generateStatsJson(const char *url_path, int *len);