kopia lustrzana https://github.com/rs1729/RS
json: optional JSON version output, global or local define
rodzic
5a4f9ebd41
commit
b388ae262e
16
c34/c50dft.c
16
c34/c50dft.c
|
@ -11,6 +11,17 @@
|
|||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
typedef unsigned char ui8_t;
|
||||
|
||||
static int option_verbose = 0,
|
||||
|
@ -325,6 +336,7 @@ static void printGPX() {
|
|||
|
||||
static void printJSON() {
|
||||
// UTC or GPS time ?
|
||||
char *ver_jsn = NULL;
|
||||
char json_sonde_id[] = "C50-xxxx\0\0\0\0\0\0\0";
|
||||
if (gpx.sn) {
|
||||
sprintf(json_sonde_id, "C50-%u", gpx.sn);
|
||||
|
@ -340,6 +352,10 @@ static void printJSON() {
|
|||
if (gpx.jsn_freq > 0) {
|
||||
printf(", \"freq\": %d", gpx.jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn);
|
||||
printf(" }\n");
|
||||
//printf("\n");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,16 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
#include "demod_mod.h"
|
||||
|
||||
|
@ -781,6 +791,7 @@ static void print_gpx(gpx_t *gpx) {
|
|||
|
||||
if (gpx->option.jsn && jsonout && gpx->sek < 60.0)
|
||||
{
|
||||
char *ver_jsn = NULL;
|
||||
unsigned long sec_gps = 0;
|
||||
int week = 0;
|
||||
int tow = 0;
|
||||
|
@ -814,6 +825,10 @@ static void print_gpx(gpx_t *gpx) {
|
|||
if (gpx->jsn_freq > 0) {
|
||||
printf(", \"freq\": %d", gpx->jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn);
|
||||
printf(" }\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -20,9 +20,15 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
//typedef unsigned char ui8_t;
|
||||
|
@ -456,8 +462,8 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) {
|
|||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
fprintf(stdout, " }\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
|
|
@ -35,6 +35,16 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
//typedef unsigned char ui8_t;
|
||||
//typedef unsigned short ui16_t;
|
||||
|
@ -752,6 +762,7 @@ static void print_frame(gpx_t *gpx, int crc_err, int len) {
|
|||
// Print JSON output required by auto_rx.
|
||||
if (crc_err==0) { // CRC-OK
|
||||
// UTC oder GPS?
|
||||
char *ver_jsn = NULL;
|
||||
char sntyp[] = "LMS6-";
|
||||
if (gpx->typ == 10) sntyp[3] = 'X';
|
||||
printf("{ \"type\": \"%s\"", "LMS");
|
||||
|
@ -764,6 +775,10 @@ static void print_frame(gpx_t *gpx, int crc_err, int len) {
|
|||
if (gpx->jsn_freq > 0) {
|
||||
printf(", \"freq\": %d", gpx->jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn);
|
||||
printf(" }\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,16 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
#include "demod_mod.h"
|
||||
|
||||
|
@ -955,6 +965,7 @@ static int print_pos(gpx_t *gpx, int csOK) {
|
|||
if (gpx->option.jsn) {
|
||||
// Print out telemetry data as JSON
|
||||
if (csOK) {
|
||||
char *ver_jsn = NULL;
|
||||
int j;
|
||||
char sn_id[4+12] = "M10-";
|
||||
ui8_t aprs_id[4];
|
||||
|
@ -1012,6 +1023,10 @@ static int print_pos(gpx_t *gpx, int csOK) {
|
|||
if (gpx->jsn_freq > 0) {
|
||||
fprintf(stdout, ", \"freq\": %d", gpx->jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
fprintf(stdout, " }\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
|
|
@ -27,6 +27,16 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
#include "demod_mod.h"
|
||||
|
||||
|
@ -635,6 +645,7 @@ static int print_pos(gpx_t *gpx, int bcOK, int csOK) {
|
|||
if (gpx->option.jsn) {
|
||||
// Print out telemetry data as JSON
|
||||
if (csOK) {
|
||||
char *ver_jsn = NULL;
|
||||
int j;
|
||||
char sn_id[4+12] = "M20-";
|
||||
double sec_gps0 = (double)gpx->week*SECONDS_IN_WEEK + gpx->tow_ms/1e3;
|
||||
|
@ -652,6 +663,10 @@ static int print_pos(gpx_t *gpx, int bcOK, int csOK) {
|
|||
if (gpx->jsn_freq > 0) {
|
||||
fprintf(stdout, ", \"freq\": %d", gpx->jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
fprintf(stdout, " }\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
|
|
@ -102,6 +102,17 @@ e.g. -b --br 2398
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
//typedef unsigned char ui8_t;
|
||||
//typedef unsigned short ui16_t;
|
||||
//typedef unsigned int ui32_t;
|
||||
|
@ -911,6 +922,7 @@ int main(int argc, char **argv) {
|
|||
printf("\n");
|
||||
|
||||
if (option_jsn && err_frm==0 && gps_err==0) {
|
||||
char *ver_jsn = NULL;
|
||||
char id_str[] = "xxxxxx\0\0\0\0\0\0";
|
||||
if (gpx.sn > 0 && gpx.sn < 1e9) {
|
||||
sprintf(id_str, "%.0f", gpx.sn);
|
||||
|
@ -922,6 +934,10 @@ int main(int argc, char **argv) {
|
|||
if (gpx.jsn_freq > 0) { // not gpx.fq, because gpx.sn not in every frame
|
||||
printf(", \"freq\": %d", gpx.jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn);
|
||||
printf(" }\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,17 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
//typedef unsigned char ui8_t;
|
||||
//typedef unsigned short ui16_t;
|
||||
//typedef unsigned int ui32_t;
|
||||
|
@ -1801,6 +1812,7 @@ static int print_position(gpx_t *gpx, int ec) {
|
|||
// Print out telemetry data as JSON
|
||||
if ((!err && !err1 && !err3) || (!err && encrypted)) { // frame-nb/id && gps-time && gps-position (crc-)ok; 3 CRCs, RS not needed
|
||||
// eigentlich GPS, d.h. UTC = GPS - 18sec (ab 1.1.2017)
|
||||
char *ver_jsn = NULL;
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "RS41");
|
||||
fprintf(stdout, ", \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f, \"sats\": %d, \"bt\": %d, \"batt\": %.2f",
|
||||
gpx->frnr, gpx->id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vV, gpx->numSV, gpx->conf_cd, gpx->batt );
|
||||
|
@ -1833,6 +1845,10 @@ static int print_position(gpx_t *gpx, int ec) {
|
|||
if (gpx->freq > 0) fq_kHz = gpx->freq;
|
||||
fprintf(stdout, ", \"freq\": %d", fq_kHz);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
fprintf(stdout, " }\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,16 @@
|
|||
#include <io.h>
|
||||
#endif
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
//typedef unsigned char ui8_t;
|
||||
//typedef unsigned short ui16_t;
|
||||
|
@ -1178,6 +1188,7 @@ static int print_position(gpx_t *gpx, int ec) { // GPS-Hoehe ueber Ellipsoid
|
|||
// Print out telemetry data as JSON //even if we don't have a valid GPS lock
|
||||
if ((gpx->crc & (crc_FRAME | crc_GPS))==0 && (gpx->gps.almanac || gpx->gps.ephem)) //(!err1 && !err3)
|
||||
{ // eigentlich GPS, d.h. UTC = GPS - UTC_OFS (UTC_OFS=18sec ab 1.1.2017)
|
||||
char *ver_jsn = NULL;
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "RS92");
|
||||
fprintf(stdout, ", \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
|
@ -1190,6 +1201,10 @@ static int print_position(gpx_t *gpx, int ec) { // GPS-Hoehe ueber Ellipsoid
|
|||
//if (gpx->freq > 0) fq_kHz = gpx->freq; // L-band: option.ngp ?
|
||||
fprintf(stdout, ", \"freq\": %d", fq_kHz);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
fprintf(stdout, " }\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
/*
|
||||
compile options
|
||||
(a) -DVERSION_JSN (set global)
|
||||
(a) -DVERSION_JSN [-I<inc_dir>] (set global)
|
||||
(b) -DVER_JSN_STR=\"0.0.2\" (set local)
|
||||
*/
|
||||
|
||||
|
|
|
@ -10,6 +10,17 @@
|
|||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
typedef unsigned char ui8_t;
|
||||
|
||||
int option_verbose = 0, // ausfuehrliche Anzeige
|
||||
|
@ -429,15 +440,19 @@ int print_frame(int len) {
|
|||
if (option_json) {
|
||||
if (gpx.gps_valid && gpx.ptu_valid) // frameNb part of PTU-pck
|
||||
{
|
||||
char *ver_jsn = NULL;
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "IMET");
|
||||
fprintf(stdout, ", \"frame\": %d, \"id\": \"iMet\", \"datetime\": \"%02d:%02d:%02dZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %d, \"sats\": %d, \"temp\": %.2f, \"humidity\": %.2f, \"pressure\": %.2f, \"batt\": %.1f",
|
||||
gpx.frame, gpx.hour, gpx.min, gpx.sec, gpx.lat, gpx.lon, gpx.alt, gpx.sats, gpx.temp, gpx.humidity, gpx.pressure, gpx.batt);
|
||||
}
|
||||
if (gpx.jsn_freq > 0) {
|
||||
fprintf(stdout, ", \"freq\": %d", gpx.jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') fprintf(stdout, ", \"version\": \"%s\"", ver_jsn);
|
||||
fprintf(stdout, " }\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (out) fprintf(stdout, "\n");
|
||||
|
|
|
@ -9,6 +9,16 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
// optional JSON "version"
|
||||
// (a) set global
|
||||
// gcc -DVERSION_JSN [-I<inc_dir>] ...
|
||||
#ifdef VERSION_JSN
|
||||
#include "version_jsn.h"
|
||||
#endif
|
||||
// or
|
||||
// (b) set local compiler option, e.g.
|
||||
// gcc -DVER_JSN_STR=\"0.0.2\" ...
|
||||
|
||||
|
||||
typedef unsigned char ui8_t;
|
||||
typedef unsigned short ui16_t;
|
||||
|
@ -639,6 +649,7 @@ void print_frame(int len) {
|
|||
if (crc_err==0 && (gpx.id & 0xFFFF0000)) { // CRC-OK and FullID
|
||||
if (gpx.prev_frnr != gpx.frnr) { //|| gpx.id != _id0
|
||||
// UTC oder GPS?
|
||||
char *ver_jsn = NULL;
|
||||
printf("{ \"type\": \"%s\"", "LMS");
|
||||
printf(", \"frame\": %d, \"id\": \"LMS6-%d\", \"datetime\": \"%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
gpx.frnr, gpx.id, gpx.std, gpx.min, gpx.sek, gpx.lat, gpx.lon, gpx.alt, gpx.vH, gpx.vD, gpx.vV );
|
||||
|
@ -646,6 +657,10 @@ void print_frame(int len) {
|
|||
if (gpx.jsn_freq > 0) {
|
||||
printf(", \"freq\": %d", gpx.jsn_freq);
|
||||
}
|
||||
#ifdef VER_JSN_STR
|
||||
ver_jsn = VER_JSN_STR;
|
||||
#endif
|
||||
if (ver_jsn && *ver_jsn != '\0') printf(", \"version\": \"%s\"", ver_jsn);
|
||||
printf(" }\n");
|
||||
printf("\n");
|
||||
gpx.prev_frnr = gpx.frnr;
|
||||
|
|
Ładowanie…
Reference in New Issue