rs41-sgm notification

pull/12/head
Zilog80 2019-04-08 22:10:44 +02:00
rodzic 3aaa626466
commit 30bba23a50
2 zmienionych plików z 98 dodań i 67 usunięć

Wyświetl plik

@ -577,7 +577,7 @@ static int get_PTU(gpx_t *gpx) {
}
printf("\n");
if (gpx->alt > -400.0)
//if (gpx->alt > -400.0)
{
printf(" %9.2f ; %6.1f ; %6.1f ", gpx->alt, gpx->ptu_Rf1, gpx->ptu_Rf2);
printf("; %10.6f ; %10.6f ; %10.6f ", gpx->ptu_calT1[0], gpx->ptu_calT1[1], gpx->ptu_calT1[2]);
@ -728,7 +728,7 @@ static int get_GPStime(gpx_t *gpx) {
static int get_GPS1(gpx_t *gpx) {
int err=0;
// gpx->frame[pos_GPS1+1] != pck_GPS1 & 0xFF ?
// gpx->frame[pos_GPS1+1] != (pck_GPS1 & 0xFF) ?
err = check_CRC(gpx, pos_GPS1, pck_GPS1);
if (err) {
gpx->crc |= crc_GPS1;
@ -747,7 +747,7 @@ static int get_GPS1(gpx_t *gpx) {
static int get_GPS2(gpx_t *gpx) {
int err=0;
// gpx->frame[pos_GPS2+1] != pck_GPS2 & 0xFF ?
// gpx->frame[pos_GPS2+1] != (pck_GPS2 & 0xFF) ?
err = check_CRC(gpx, pos_GPS2, pck_GPS2);
if (err) gpx->crc |= crc_GPS2;
@ -854,7 +854,7 @@ static int get_GPSkoord(gpx_t *gpx) {
static int get_GPS3(gpx_t *gpx) {
int err=0;
// gpx->frame[pos_GPS3+1] != pck_GPS3 & 0xFF ?
// gpx->frame[pos_GPS3+1] != (pck_GPS3 & 0xFF) ?
err = check_CRC(gpx, pos_GPS3, pck_GPS3);
if (err) {
gpx->crc |= crc_GPS3;
@ -1210,7 +1210,7 @@ static int print_position(gpx_t *gpx, int ec) {
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)
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",
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->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 );
if (gpx->option.ptu && !err0 && gpx->T > -273.0) {
fprintf(stdout, ", \"temp\": %.1f", gpx->T );
}

Wyświetl plik

@ -264,6 +264,8 @@ int check_CRC(ui32_t pos, ui32_t pck) {
/*
GPS chip: ublox UBX-G6010-ST
Pos: SubHeader, 1+1 byte (ID+LEN)
0x039: 7928 FrameNumber+SondeID
+(0x050: 0732 CalFrames 0x00..0x32)
@ -330,6 +332,7 @@ int check_CRC(ui32_t pos, ui32_t pck) {
#define pck_ZEROstd 0x7611 // NDATA std-frm, no aux
#define pos_ZEROstd 0x12B // pos_AUX(0)
#define pck_ENCRYPTED 0x8000 // Packet type for an Encrypted payload
/*
frame[pos_FRAME-1] == 0x0F: len == NDATA_LEN(320)
@ -367,6 +370,10 @@ int get_SatData() {
int numSV;
double pDOP, sAcc;
if ( ((frame[pos_GPS1]<<8) | frame[pos_GPS1+1]) != pck_GPS1 ) return -1;
if ( ((frame[pos_GPS2]<<8) | frame[pos_GPS2+1]) != pck_GPS2 ) return -2;
if ( ((frame[pos_GPS3]<<8) | frame[pos_GPS3+1]) != pck_GPS3 ) return -3;
fprintf(stdout, "[%d]\n", u2(frame+pos_FrameNb));
fprintf(stdout, "iTOW: 0x%08X", u4(frame+pos_GPSiTOW));
@ -714,15 +721,16 @@ int get_GPStime() {
int get_GPS1() {
int err=0;
// ((framebyte(pos_GPS1)<<8) | framebyte(pos_GPS1+1)) != pck_GPS1 ?
if ( framebyte(pos_GPS1) != ((pck_GPS1>>8) & 0xFF) ) {
// framebyte(pos_GPS1+1) != (pck_GPS1 & 0xFF) ?
err = check_CRC(pos_GPS1, pck_GPS1);
if (err) {
gpx.crc |= crc_GPS1;
// reset GPS1-data (json)
gpx.jahr = 0; gpx.monat = 0; gpx.tag = 0;
gpx.std = 0; gpx.min = 0; gpx.sek = 0.0;
return -1;
}
err = check_CRC(pos_GPS1, pck_GPS1);
if (err) gpx.crc |= crc_GPS1;
err |= get_GPSweek(); // no plausibility-check
err |= get_GPStime(); // no plausibility-check
@ -732,6 +740,7 @@ int get_GPS1() {
int get_GPS2() {
int err=0;
// framebyte(pos_GPS2+1) != (pck_GPS2 & 0xFF) ?
err = check_CRC(pos_GPS2, pck_GPS2);
if (err) gpx.crc |= crc_GPS2;
@ -833,15 +842,17 @@ int get_GPSkoord() {
int get_GPS3() {
int err=0;
// ((framebyte(pos_GPS3)<<8) | framebyte(pos_GPS3+1)) != pck_GPS3 ?
if ( framebyte(pos_GPS3) != ((pck_GPS3>>8) & 0xFF) ) {
// framebyte(pos_GPS3+1) != (pck_GPS3 & 0xFF) ?
err = check_CRC(pos_GPS3, pck_GPS3);
if (err) {
gpx.crc |= crc_GPS3;
// reset GPS3-data (json)
gpx.lat = 0.0; gpx.lon = 0.0; gpx.alt = 0.0;
gpx.vH = 0.0; gpx.vD = 0.0; gpx.vU = 0.0;
gpx.numSV = 0;
return -1;
}
err = check_CRC(pos_GPS3, pck_GPS3);
if (err) gpx.crc |= crc_GPS3;
err |= get_GPSkoord(); // plausibility-check: altitude, if ecef=(0,0,0)
return err;
@ -1085,6 +1096,14 @@ int print_position(int ec) {
int i;
int err, err0, err1, err2, err3;
int output, out_mask;
int encrypted = 0;
// Quick check for an encrypted packet (RS41-SGM)
// These sondes have a type 0x80 packet in place of the regular PTU packet.
if (check_CRC(pos_PTU, pck_ENCRYPTED)==0) { // frame[pos_PTU] == pck_ENCRYPTED>>8
encrypted = 1; // and CRC-OK
// Continue with the rest of the extraction
}
err = get_FrameConf();
@ -1103,6 +1122,9 @@ int print_position(int ec) {
fprintf(stdout, "[%5d] ", gpx.frnr);
fprintf(stdout, "(%s) ", gpx.id);
}
if (encrypted) { // e.g. 0x80A7-pck
fprintf(stdout, " (RS41-SGM: %02X%02X) ", frame[pos_PTU], frame[pos_PTU+1]);
}
if (!err1) {
Gps2Date(gpx.week, gpx.gpssec, &gpx.jahr, &gpx.monat, &gpx.tag);
fprintf(stdout, "%s ", weekday[gpx.wday]);
@ -1169,13 +1191,22 @@ int print_position(int ec) {
if (option_json) {
// Print JSON output required by auto_rx.
if (!err && !err1 && !err3) { // frame-nb/id && gps-time && gps-position (crc-)ok; 3 CRCs, RS not needed
if ((!err && !err1 && !err3) || (!err && encrypted)) { // frame-nb/id && gps-time && gps-position (crc-)ok; 3 CRCs, RS not needed
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",
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.vU, gpx.numSV );
if (option_ptu && !err0 && gpx.T > -273.0) {
printf("{ \"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, \"temp\":%.1f }\n", 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.vU, gpx.numSV, gpx.T );
} else {
printf("{ \"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 }\n", 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.vU, gpx.numSV );
fprintf(stdout, ", \"temp\": %.1f", gpx.T );
}
printf("\n");
/*
if (option_ptu && !err0 && gpx.RH > -0.5) {
fprintf(stdout, ", \"humidity\": %.1f", gpx.RH );
}
*/
if (encrypted){
fprintf(stdout, ", \"encrypted\": true");
}
fprintf(stdout, " }\n");
fprintf(stdout, "\n");
}
}