rs_multi: sync dfm09

pull/53/head
Zilog80 2022-11-28 00:20:40 +01:00
rodzic 3a9a87fde4
commit 015137ccfc
1 zmienionych plików z 45 dodań i 31 usunięć

Wyświetl plik

@ -27,6 +27,7 @@ enum dfmtyp_keys_t {
UNDEF, UNDEF,
UNKNW, UNKNW,
DFM06, DFM06,
DFM06P,
PS15, PS15,
DFM09, DFM09,
DFM09P, DFM09P,
@ -38,6 +39,7 @@ static char *DFM_types[] = {
[UNDEF] = "", [UNDEF] = "",
[UNKNW] = "DFMxX", [UNKNW] = "DFMxX",
[DFM06] = "DFM06", [DFM06] = "DFM06",
[DFM06P] = "DFM06P",
[PS15] = "PS15", [PS15] = "PS15",
[DFM09] = "DFM09", [DFM09] = "DFM09",
[DFM09P] = "DFM09P", [DFM09P] = "DFM09P",
@ -77,7 +79,8 @@ typedef struct {
typedef struct { typedef struct {
ui32_t prn; // SVs used (PRN) ui32_t prn; // SVs used (PRN)
float dMSL; // Alt_MSL - Alt_ellipsoid = -N = - geoid_height = ellipsoid - geoid float dMSL; // Alt_MSL - Alt_ellipsoid = -N = - geoid_height = ellipsoid - geoid
ui8_t nSV; // numSVs used ui8_t nSV; // numSVs used
ui8_t nPRN; // numSVs in in PRN list
} gpsdat_t; } gpsdat_t;
#define BITFRAME_LEN 280 #define BITFRAME_LEN 280
@ -88,6 +91,7 @@ typedef struct {
int sonde_typ; int sonde_typ;
ui32_t SN6; ui32_t SN6;
ui32_t SN; ui32_t SN;
char SN_out[10];
int week; int tow; ui32_t sec_gps; int week; int tow; ui32_t sec_gps;
int jahr; int monat; int tag; int jahr; int monat; int tag;
int std; int min; float sek; int std; int min; float sek;
@ -112,7 +116,7 @@ typedef struct {
pcksts_t pck[9]; pcksts_t pck[9];
option_t option; option_t option;
int ptu_out; int ptu_out;
char sensortyp0xC; char sensortyp;
char *dfmtyp; char *dfmtyp;
int jsn_freq; // freq/kHz (SDR) int jsn_freq; // freq/kHz (SDR)
gpsdat_t gps; gpsdat_t gps;
@ -313,7 +317,8 @@ static int dat_out(gpx_t *gpx, ui8_t *dat_bits, int ec) {
} }
if (fr_id == 1) { if (fr_id == 1) {
// 00..31: GPS-Sats in solution (bitmap) // 00..31: GPS-Sats in solution (bitmap)
gpx->gps.prn = bits2val(dat_bits, 32); // SV/PRN used gpx->gps.prn = bits2val(dat_bits, 32); // SV/PRN bitmask
gpx->gps.nPRN = 0; for (int j = 0; j < 32; j++) { if ((gpx->gps.prn >> j)&1) gpx->gps.nPRN += 1; }
msek = bits2val(dat_bits+32, 16); // UTC (= GPS - 18sec ab 1.1.2017) msek = bits2val(dat_bits+32, 16); // UTC (= GPS - 18sec ab 1.1.2017)
gpx->sek = msek/1000.0; gpx->sek = msek/1000.0;
} }
@ -488,7 +493,8 @@ static float get_Temp(gpx_t *gpx) { // meas[0..4]
float f = gpx->meas24[0], float f = gpx->meas24[0],
f1 = gpx->meas24[3], f1 = gpx->meas24[3],
f2 = gpx->meas24[4]; f2 = gpx->meas24[4];
if (gpx->sensortyp0xC == 'P') { // 0xC: "P+" DFM-09P , "T-" DFM-17TU ; 0xD: "P-" DFM-17P ? if (gpx->sensortyp == 'P') // 0xC: "P+" DFM-09P , "T-" DFM-17TU ; 0xD: "P-" DFM-17P ?
{ // 0x8: "P-" (gpx->sonde_id[3] == '8') DFM-6/9P ?
f = gpx->meas24[0+1]; f = gpx->meas24[0+1];
f1 = gpx->meas24[3+2]; f1 = gpx->meas24[3+2];
f2 = gpx->meas24[4+2]; f2 = gpx->meas24[4+2];
@ -520,7 +526,7 @@ static float get_Temp2(gpx_t *gpx) { // meas[0..4]
float f = gpx->meas24[0], float f = gpx->meas24[0],
f1 = gpx->meas24[3], f1 = gpx->meas24[3],
f2 = gpx->meas24[4]; f2 = gpx->meas24[4];
if (gpx->ptu_out >= 0xC && gpx->meas24[6] < 220e3) { if (gpx->ptu_out >= 0xC && gpx->meas24[6] < 220e3 || gpx->sonde_id[3] == '8') {
f = gpx->meas24[0+1]; f = gpx->meas24[0+1];
f1 = gpx->meas24[3+2]; f1 = gpx->meas24[3+2];
f2 = gpx->meas24[4+2]; f2 = gpx->meas24[4+2];
@ -585,7 +591,7 @@ static float get_Temp4(gpx_t *gpx) { // meas[0..4]
float f = gpx->meas24[0], float f = gpx->meas24[0],
f1 = gpx->meas24[3], f1 = gpx->meas24[3],
f2 = gpx->meas24[4]; f2 = gpx->meas24[4];
if (gpx->ptu_out >= 0xC && gpx->meas24[6] < 220e3) { if (gpx->ptu_out >= 0xC && gpx->meas24[6] < 220e3 || gpx->sonde_id[3] == '8') {
f = gpx->meas24[0+1]; f = gpx->meas24[0+1];
f1 = gpx->meas24[3+2]; f1 = gpx->meas24[3+2];
f2 = gpx->meas24[4+2]; f2 = gpx->meas24[4+2];
@ -607,6 +613,8 @@ static int reset_cfgchk(gpx_t *gpx) {
for (j = 0; j < 9; j++) gpx->cfgchk24[j] = 0; for (j = 0; j < 9; j++) gpx->cfgchk24[j] = 0;
gpx->cfgchk = 0; gpx->cfgchk = 0;
gpx->ptu_out = 0; gpx->ptu_out = 0;
//gpx->gps.dMSL = 0;
*gpx->SN_out = '\0';
return 0; return 0;
} }
@ -651,12 +659,15 @@ static int conf_out(gpx_t *gpx, ui8_t *conf_bits, int ec) {
sn2_ch = bits2val(conf_bits, 8); sn2_ch = bits2val(conf_bits, 8);
sn_ch = ((sn2_ch>>4) & 0xF); // sn_ch == config_id sn_ch = ((sn2_ch>>4) & 0xF); // sn_ch == config_id
if ( (gpx->snc.nul_ch & 0x58) == 0x58 ) { // 0x5A, 0x5B if ( (gpx->snc.nul_ch & 0x58) == 0x58 ) { // 0x5A, 0x5B or 0x7A, 0x7B
SN6 = bits2val(conf_bits+4, 4*6); // DFM-06: Kanal 6 SN6 = bits2val(conf_bits+4, 4*6); // DFM-06: Kanal 6 DFM-06P: Kanal 8 (DFM-6/9P)
if (SN6 == gpx->SN6 && SN6 != 0) { // nur Nibble-Werte 0..9 if (SN6 == gpx->SN6 && SN6 != 0) { // nur Nibble-Werte 0..9
gpx->sonde_typ = SNbit | 6; gpx->sonde_typ = SNbit | sn_ch; //6 or 8
gpx->ptu_out = 6; // <-> DFM-06 gpx->ptu_out = 6; // <-> DFM-06
sprintf(gpx->sonde_id, "IDx%1X:%6X", gpx->sonde_typ & 0xF, gpx->SN6); // (test SN6 for BCD (binary coded decimal) ?)
//sprintf(gpx->sonde_id, "IDx%1X:%6X", gpx->sonde_typ & 0xF, gpx->SN6);
sprintf(gpx->sonde_id, "IDx%1X:%6X", sn_ch & 0xF, gpx->SN6);
sprintf(gpx->SN_out, "%6X", gpx->SN6);
} }
else { // reset else { // reset
gpx->sonde_typ = 0; gpx->sonde_typ = 0;
@ -695,8 +706,9 @@ static int conf_out(gpx_t *gpx, ui8_t *conf_bits, int ec) {
if (sn_ch == 0xD) gpx->ptu_out = sn_ch; // <-> DFM-17P(?) if (sn_ch == 0xD) gpx->ptu_out = sn_ch; // <-> DFM-17P(?)
// PS-15 ? (sn2_ch & 0xF) == 0x0 : gpx->ptu_out = 0 // <-> PS-15 // PS-15 ? (sn2_ch & 0xF) == 0x0 : gpx->ptu_out = 0 // <-> PS-15
if ( (gpx->sonde_typ & 0xF) > 6) { if ( gpx->SN6 == 0 || (gpx->sonde_typ & 0xF) >= 0xA) {
sprintf(gpx->sonde_id, "IDx%1X:%6u", gpx->sonde_typ & 0xF, gpx->SN); sprintf(gpx->sonde_id, "IDx%1X:%6u", gpx->sonde_typ & 0xF, gpx->SN);
sprintf(gpx->SN_out, "%6u", gpx->SN);
} }
} }
else { // reset else { // reset
@ -712,7 +724,7 @@ static int conf_out(gpx_t *gpx, ui8_t *conf_bits, int ec) {
} }
if (conf_id >= 0 && conf_id <= 8) { if (conf_id >= 0 && conf_id <= 8 && ec == 0) {
gpx->cfgchk24[conf_id] = 1; gpx->cfgchk24[conf_id] = 1;
val = bits2val(conf_bits+4, 4*6); val = bits2val(conf_bits+4, 4*6);
gpx->val24[conf_id] = val; gpx->val24[conf_id] = val;
@ -730,19 +742,23 @@ static int conf_out(gpx_t *gpx, ui8_t *conf_bits, int ec) {
if (gpx->ptu_out >= 0x8) gpx->cfgchk *= gpx->cfgchk24[8]; if (gpx->ptu_out >= 0x8) gpx->cfgchk *= gpx->cfgchk24[8];
} }
gpx->sensortyp0xC = 'T'; gpx->sensortyp = 'T';
gpx->Rf = 220e3; gpx->Rf = 220e3;
if (gpx->cfgchk) if (gpx->cfgchk)
{ // 0xC: "P+" DFM-09P , "T-" DFM-17TU ; 0xD: "P-" DFM-17P ? { // 0xC: "P+" DFM-09P , "T-" DFM-17TU ; 0xD: "P-" DFM-17P ?
if (gpx->ptu_out >= 0xD || (gpx->ptu_out >= 0xC && gpx->meas24[6] < 220e3)) { // gpx->meas24[6] < 220e3 <=> gpx->meas24[0] > 1e6 ? if (gpx->ptu_out >= 0xD || (gpx->ptu_out >= 0xC && gpx->meas24[6] < 220e3)) { // gpx->meas24[6] < 220e3 <=> gpx->meas24[0] > 2e5 ?
gpx->sensortyp0xC = 'P'; // gpx->meas24[0] > 1e6 ? gpx->sensortyp = 'P'; // gpx->meas24[0] > 2e5 ?
}
if ( ((gpx->ptu_out == 0xB || gpx->ptu_out == 0xC) && gpx->sensortyp == 'T') || gpx->ptu_out >= 0xD) gpx->Rf = 332e3; // DFM-17 ?
if (gpx->ptu_out == 6 && (gpx->sonde_typ & 0xF) == 8) {
gpx->sensortyp = 'P';
} }
if ( ((gpx->ptu_out == 0xB || gpx->ptu_out == 0xC) && gpx->sensortyp0xC == 'T') || gpx->ptu_out >= 0xD) gpx->Rf = 332e3; // DFM-17 ?
// STM32-status: Bat, MCU-Temp // STM32-status: Bat, MCU-Temp
if (gpx->ptu_out >= 0xA) { // DFM>=09(P) (STM32) if (gpx->ptu_out >= 0xA) { // DFM>=09(P) (STM32)
ui8_t ofs = 0; ui8_t ofs = 0;
if (gpx->sensortyp0xC == 'P') ofs = 2; if (gpx->sensortyp == 'P') ofs = 2;
// //
// c0xxxx0 inner 16 bit // c0xxxx0 inner 16 bit
if (conf_id == 0x5+ofs) { // voltage if (conf_id == 0x5+ofs) { // voltage
@ -778,14 +794,15 @@ static int conf_out(gpx_t *gpx, ui8_t *conf_bits, int ec) {
case 0x6: gpx->dfmtyp = DFM_types[DFM06]; case 0x6: gpx->dfmtyp = DFM_types[DFM06];
break; break;
case 0x7: case 0x7:
case 0x8: gpx->dfmtyp = DFM_types[PS15]; case 0x8: if (gpx->SN6) gpx->dfmtyp = DFM_types[DFM06P]; //gpx->sensortyp == 'P'
else gpx->dfmtyp = DFM_types[PS15];
break; break;
case 0xA: gpx->dfmtyp = DFM_types[DFM09]; case 0xA: gpx->dfmtyp = DFM_types[DFM09];
break; break;
case 0xB: gpx->dfmtyp = DFM_types[DFM17]; case 0xB: gpx->dfmtyp = DFM_types[DFM17];
break; break;
case 0xC: if (gpx->sensortyp0xC == 'P') gpx->dfmtyp = DFM_types[DFM09P]; case 0xC: if (gpx->sensortyp == 'P') gpx->dfmtyp = DFM_types[DFM09P];
else /*'T'*/ gpx->dfmtyp = DFM_types[DFM17]; else /*'T'*/ gpx->dfmtyp = DFM_types[DFM17];
break; break;
case 0xD: gpx->dfmtyp = DFM_types[DFM17P]; case 0xD: gpx->dfmtyp = DFM_types[DFM17P];
break; break;
@ -888,7 +905,7 @@ static int print_gpx(gpx_t *gpx) {
float t = get_Temp(gpx); float t = get_Temp(gpx);
if (t > -270.0) { if (t > -270.0) {
printf(" T=%.1fC ", t); // 0xC:P+ DFM-09P , 0xC:T- DFM-17TU , 0xD:P- DFM-17P ? printf(" T=%.1fC ", t); // 0xC:P+ DFM-09P , 0xC:T- DFM-17TU , 0xD:P- DFM-17P ?
if (gpx->option.vbs == 3) printf(" (0x%X:%c%c) ", gpx->sonde_typ & 0xF, gpx->sensortyp0xC, gpx->option.inv?'-':'+'); if (gpx->option.vbs == 3) printf(" (0x%X:%c%c) ", gpx->sonde_typ & 0xF, gpx->sensortyp, gpx->option.inv?'-':'+');
} }
if (gpx->option.dbg) { if (gpx->option.dbg) {
float t2 = get_Temp2(gpx); float t2 = get_Temp2(gpx);
@ -909,7 +926,7 @@ static int print_gpx(gpx_t *gpx) {
printf(" f2:%.1f", gpx->meas24[2]); printf(" f2:%.1f", gpx->meas24[2]);
printf(" f3:%.1f", gpx->meas24[3]); printf(" f3:%.1f", gpx->meas24[3]);
printf(" f4:%.1f", gpx->meas24[4]); printf(" f4:%.1f", gpx->meas24[4]);
if (gpx->ptu_out >= 0xA /*0xC*/) { if (gpx->ptu_out >= 0xA /*0xC*/ || gpx->sonde_id[3] == '8') {
printf(" f5:%.1f", gpx->meas24[5]); printf(" f5:%.1f", gpx->meas24[5]);
printf(" f6:%.1f", gpx->meas24[6]); printf(" f6:%.1f", gpx->meas24[6]);
} }
@ -971,6 +988,7 @@ static int print_gpx(gpx_t *gpx) {
printf(" sats: %d", gpx->gps.nSV); printf(" sats: %d", gpx->gps.nSV);
printf(" ("); printf(" (");
for (j = 0; j < 32; j++) { if ((gpx->gps.prn >> j)&1) printf(" %02d", j+1); } for (j = 0; j < 32; j++) { if ((gpx->gps.prn >> j)&1) printf(" %02d", j+1); }
printf(" nPRN: %d", gpx->gps.nPRN);
printf(" )"); printf(" )");
printf("\n"); printf("\n");
} }
@ -978,23 +996,19 @@ static int print_gpx(gpx_t *gpx) {
if (gpx->option.jsn && jsonout && gpx->sek < 60.0) if (gpx->option.jsn && jsonout && gpx->sek < 60.0)
{ {
char json_sonde_id[] = "DFM-xxxxxxxx\0\0"; char json_sonde_id[] = "DFM-xxxxxxxx\0\0"; // default (dfmXtyp==0)
ui8_t dfmXtyp = (gpx->sonde_typ & 0xF); ui8_t dfmXtyp = (gpx->sonde_typ & 0xF);
switch ( dfmXtyp ) { if (*gpx->SN_out) strncpy(json_sonde_id+4, gpx->SN_out, 9);
case 0: sprintf(json_sonde_id, "DFM-xxxxxxxx"); break; //json_sonde_id[0] = '\0';
case 6: sprintf(json_sonde_id, "DFM-%6X", gpx->SN6); break; // DFM-06
case 0xA: sprintf(json_sonde_id, "DFM-%6u", gpx->SN); break; // DFM-09
// 0x7:PS-15?, 0xB:DFM-17? 0xC:DFM-09P?DFM-17TU? 0xD:DFM-17P?
default : sprintf(json_sonde_id, "DFM-%6u", gpx->SN);
}
// JSON frame counter: gpx->sec_gps , seconds since GPS (ignoring leap seconds, DFM=UTC) // JSON frame counter: gpx->sec_gps , seconds since GPS (ignoring leap seconds, DFM=UTC)
int _sats = gpx->gps.nSV;
if (_sats == 0 /*&& sonde_type == 6*/) _sats = gpx->gps.nPRN;
// Print JSON blob // valid sonde_ID? // Print JSON blob // valid sonde_ID?
printf("{ \"type\": \"%s\"", "DFM"); printf("{ \"type\": \"%s\"", "DFM");
printf(", \"frame\": %u, ", gpx->sec_gps); // gpx->frnr printf(", \"frame\": %u, ", gpx->sec_gps); // gpx->frnr
printf("\"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", printf("\"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",
json_sonde_id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->horiV, gpx->dir, gpx->vertV, gpx->gps.nSV); json_sonde_id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->horiV, gpx->dir, gpx->vertV, _sats);
if (gpx->ptu_out >= 0xA && gpx->status[0] > 0) { // DFM>=09(P): Battery (STM32) if (gpx->ptu_out >= 0xA && gpx->status[0] > 0) { // DFM>=09(P): Battery (STM32)
printf(", \"batt\": %.2f", gpx->status[0]); printf(", \"batt\": %.2f", gpx->status[0]);
} }