diff --git a/auto_rx/autorx/__init__.py b/auto_rx/autorx/__init__.py index 21a75b4..4040445 100644 --- a/auto_rx/autorx/__init__.py +++ b/auto_rx/autorx/__init__.py @@ -17,7 +17,7 @@ except ImportError: # MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus. # PATCH - Small changes, or minor feature additions. -__version__ = "1.5.6-beta1" +__version__ = "1.5.6-beta2" # Global Variables diff --git a/auto_rx/autorx/decode.py b/auto_rx/autorx/decode.py index 9b4af7b..da64185 100644 --- a/auto_rx/autorx/decode.py +++ b/auto_rx/autorx/decode.py @@ -1326,7 +1326,7 @@ class SondeDecoder(object): ) _telemetry["id"] = self.imet_id - # iMet-54 Specific Actions + # iMet-5x Specific Actions if self.sonde_type == "IMET5": # Fix up the time. _telemetry["datetime_dt"] = fix_datetime(_telemetry["datetime"]) diff --git a/auto_rx/autorx/logger.py b/auto_rx/autorx/logger.py index bdb29df..40697b2 100644 --- a/auto_rx/autorx/logger.py +++ b/auto_rx/autorx/logger.py @@ -130,6 +130,11 @@ class TelemetryLogger(object): telemetry (dict): Telemetry dictionary to process. """ # timestamp,serial,frame,lat,lon,alt,vel_v,vel_h,heading,temp,humidity,type,freq,other + if 'subtype' in telemetry: + _type = telemetry['subtype'] + else: + _type = telemetry['type'] + _log_line = "%s,%s,%d,%.5f,%.5f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%s,%.3f" % ( telemetry["datetime"], telemetry["id"], @@ -143,7 +148,7 @@ class TelemetryLogger(object): telemetry["temp"], telemetry["humidity"], telemetry["pressure"], - telemetry["type"], + _type, telemetry["freq_float"], ) diff --git a/auto_rx/autorx/sondehub.py b/auto_rx/autorx/sondehub.py index 42c8485..998eccf 100644 --- a/auto_rx/autorx/sondehub.py +++ b/auto_rx/autorx/sondehub.py @@ -199,8 +199,11 @@ class SondehubUploader(object): elif telemetry["type"] == "IMET5": _output["manufacturer"] = "Intermet Systems" - _output["type"] = "iMet-54" + _output["type"] = "iMet-5x" _output["serial"] = telemetry["id"].split("-")[1] + if "subtype" in telemetry: + _output["type"] = telemetry["subtype"] + _output["subtype"] = telemetry["subtype"] elif telemetry["type"] == "MEISEI": _output["manufacturer"] = "Meisei" diff --git a/demod/mod/imet54mod.c b/demod/mod/imet54mod.c index 3be89cb..ba3d17f 100644 --- a/demod/mod/imet54mod.c +++ b/demod/mod/imet54mod.c @@ -123,11 +123,7 @@ static int deinter64(ui8_t *in, ui8_t *out, int len) { while (n+64 <= len) { for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) bits64[i][j] = in[n + 8*i+j]; - } - for (i = 0; i < 8; i++) { - //for (j = 0; j < 8; j++) out[n + 8*i+j] = bits64[j][7-i]; - for (j = 0; j < 8; j++) out[n + 8*i+j] = bits64[j][i]; + for (j = 0; j < 8; j++) out[n + 8*j+i] = in[n + 8*i+j]; } n += 64; } @@ -265,6 +261,10 @@ static ui16_t u2be(ui8_t *bytes) { // 16bit unsigned int #define pos_PTU_T 0x1C // float32 #define pos_PTU_RH 0x20 // float32 #define pos_PTU_Trh 0x24 // float32 // ? +// +#define pos_STATUS 0x2A // 2 byte +#define pos_F8 0x52 // 1 byte +#define pos_CNT11 0x5E // 1 byte static int get_SN(gpx_t *gpx) { @@ -326,11 +326,13 @@ static int get_PTU(gpx_t *gpx) { int val = 0; float *f = (float*)&val; float rh = -1.0f; + int count_1e9 = 0; // air temperature val = i4be(gpx->frame + pos_PTU_T); if (*f > -120.0f && *f < 80.0f) gpx->T = *f; else gpx->T = -273.15f; + if (val == 0x4E6E6B28) count_1e9 += 1; // raw RH? // water vapor saturation pressure (Hyland and Wexler)? @@ -339,24 +341,26 @@ static int get_PTU(gpx_t *gpx) { if (*f < 0.0f) gpx->_RH = 0.0f; else if (*f > 100.0f) gpx->_RH = 100.0f; else gpx->_RH = *f; + if (val == 0x4E6E6B28) count_1e9 += 1; // temperatur of r.h. sensor? val = i4be(gpx->frame + pos_PTU_Trh); if (*f > -120.0f && *f < 80.0f) gpx->Trh = *f; else gpx->Trh = -273.15f; + if (val == 0x4E6E6B28) count_1e9 += 1; // (Hyland and Wexler) if (gpx->T > -273.0f && gpx->Trh > -273.0f) { rh = gpx->_RH * vaporSatP(gpx->Trh)/vaporSatP(gpx->T); - if (rh < 0.0f) rh = 0.0; - if (rh > 100.0f) rh = 100.0; + if (rh < 0.0f) rh = 0.0f; + if (rh > 100.0f) rh = 100.0f; } else { // if Trh unusable, sensor damaged? // rh = gpx->_RH; } gpx->RH = rh; - return 0; + return count_1e9; } static int reset_gpx(gpx_t *gpx) { @@ -384,9 +388,13 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) { int prnGPS = 0, prnPTU = 0, prnSTS = 0; - int frm_ok = 0; + int ptu1e9 = 0; + int pos_ok = 0, + frm_ok = 0; + int rs_type = 54; - frm_ok = (ecc_frm >= 0 && len > pos_PTU_Trh+4); + pos_ok = (ecc_frm >= 0 && len > pos_STATUS+2); + frm_ok = (ecc_frm >= 0 && len > pos_F8); reset_gpx(gpx); @@ -398,14 +406,21 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) { } if (len > pos_PTU_Trh+4) { - get_PTU(gpx); + ptu1e9 = get_PTU(gpx); prnPTU = 1; } - if (len > 42+2) { - gpx->status = u2be(gpx->frame + 42); + if (len > pos_STATUS+2) { + gpx->status = u2be(gpx->frame + pos_STATUS); prnSTS = 1; } - + if (frm_ok) { + int pos; + int sum = 0; + for (pos = pos_STATUS+2; pos < pos_F8; pos++) { + sum += gpx->frame[pos]; + } + if (sum == 0 && (gpx->status&0xF0F)==0 && ptu1e9 == 3) rs_type = 50; + } if ( prnGPS && !gpx->option.slt ) { @@ -426,7 +441,7 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) { if (gpx->RH > -0.5f) fprintf(stdout, " RH=%.0f%% ", gpx->RH); } - // (GPS) status: 003E + // (imet54:GPS+PTU) status: 003E , (imet50:GPS); 0030 if (gpx->option.vbs && prnSTS) { fprintf(stdout, " [%04X] ", gpx->status); } @@ -443,10 +458,11 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) { // prnGPS,prnTPU if (gpx->option.jsn && frm_ok && (gpx->status&0x30)==0x30) { char *ver_jsn = NULL; + char *subtype = (rs_type == 54) ? "iMet-54" : "iMet-50"; unsigned long count_day = (unsigned long)(gpx->std*3600 + gpx->min*60 + gpx->sek+0.5); // (gpx->timems/1e3+0.5) has gaps fprintf(stdout, "{ \"type\": \"%s\"", "IMET5"); fprintf(stdout, ", \"frame\": %lu", count_day); - fprintf(stdout, ", \"id\": \"IMET54-%u\", \"datetime\": \"%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f", + fprintf(stdout, ", \"id\": \"IMET5-%u\", \"datetime\": \"%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f", gpx->SNu32, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt); if (gpx->option.ptu) { if (gpx->T > -273.0f) { @@ -456,7 +472,7 @@ static int print_position(gpx_t *gpx, int len, int ecc_frm, int ecc_gps) { fprintf(stdout, ", \"humidity\": %.1f", gpx->RH ); } } - //fprintf(stdout, ", \"subtype\": \"%s\"", "IMET54"); + fprintf(stdout, ", \"subtype\": \"%s\"", subtype); // "IMET54"/"IMET50" if (gpx->jsn_freq > 0) { fprintf(stdout, ", \"freq\": %d", gpx->jsn_freq); } @@ -487,8 +503,6 @@ static void print_frame(gpx_t *gpx, int len, int b2B) { memset(bits8n1, 0, BITFRAME_LEN+10); memset(bits, 0, BITFRAME_LEN); - memset(bits, 0, BITFRAME_LEN); - de8n1(gpx->frame_bits, bits8n1, len); len = (8*len)/10;