kopia lustrzana https://github.com/projecthorus/radiosonde_auto_rx
Rebase dfm and MTS01 decoders
rodzic
18dded84b6
commit
8362717ca6
|
@ -12,7 +12,7 @@ from queue import Queue
|
||||||
# MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus.
|
# 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.
|
# PATCH - Small changes, or minor feature additions.
|
||||||
|
|
||||||
__version__ = "1.6.0-beta20"
|
__version__ = "1.6.0-beta21"
|
||||||
|
|
||||||
|
|
||||||
# Global Variables
|
# Global Variables
|
||||||
|
|
|
@ -141,7 +141,7 @@ def strip_sonde_serial(serial):
|
||||||
""" Strip off any leading sonde type that may be present in a serial number """
|
""" Strip off any leading sonde type that may be present in a serial number """
|
||||||
|
|
||||||
# Look for serials with prefixes matching the following known sonde types.
|
# Look for serials with prefixes matching the following known sonde types.
|
||||||
_re = re.compile("^(DFM|M10|M20|IMET|IMET5|IMET54|MRZ|LMS6|IMS100|MTS01)-")
|
_re = re.compile("^(DFM|M10|M20|IMET|IMET5|IMET54|MRZ|LMS6|IMS100|RS11G|MTS01)-")
|
||||||
|
|
||||||
# If we have a match, return the trailing part of the serial, re-adding
|
# If we have a match, return the trailing part of the serial, re-adding
|
||||||
# any - separators if they exist.
|
# any - separators if they exist.
|
||||||
|
|
|
@ -800,7 +800,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;
|
||||||
|
@ -822,8 +822,8 @@ static int conf_out(gpx_t *gpx, ui8_t *conf_bits, int ec) {
|
||||||
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->sensortyp = '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 == 0xB || gpx->ptu_out == 0xC) && gpx->sensortyp == 'T') || gpx->ptu_out >= 0xD) gpx->Rf = 332e3; // DFM-17 ?
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,9 @@ typedef struct {
|
||||||
int year; int month; int day;
|
int year; int month; int day;
|
||||||
int hrs; int min; int sec;
|
int hrs; int min; int sec;
|
||||||
double lat; double lon; double alt;
|
double lat; double lon; double alt;
|
||||||
|
double vH; double vD;
|
||||||
|
float T; float RH;
|
||||||
|
int batt;
|
||||||
char ID[8+4];
|
char ID[8+4];
|
||||||
ui8_t frame_bytes[FRAMELEN+4];
|
ui8_t frame_bytes[FRAMELEN+4];
|
||||||
char frame_bits[BITFRAMELEN+8];
|
char frame_bits[BITFRAMELEN+8];
|
||||||
|
@ -133,6 +136,18 @@ static int fn(gpx_t *gpx, int n) {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float get_Temp(float R) {
|
||||||
|
// Thermistor approximation
|
||||||
|
// 1/T = 1/To + 1/B log(r) , r=R/Ro
|
||||||
|
float B0 = 3000.0; // B/Kelvin
|
||||||
|
float T0 = 0.0 + 273.15;
|
||||||
|
float R0 = 15.0;
|
||||||
|
float T = 0; // T/Kelvin
|
||||||
|
if (R > 0) T = 1.0/(1.0/T0 + 1.0/B0 * log(R/R0));
|
||||||
|
return T - 273.15; // Celsius
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int print_frame(gpx_t *gpx, int pos) {
|
static int print_frame(gpx_t *gpx, int pos) {
|
||||||
int i, j;
|
int i, j;
|
||||||
int crcdat, crcval, crc_ok;
|
int crcdat, crcval, crc_ok;
|
||||||
|
@ -195,6 +210,9 @@ static int print_frame(gpx_t *gpx, int pos) {
|
||||||
gpx->month = atoi(datetime_str+ 2); datetime_str[ 2] = '\0';
|
gpx->month = atoi(datetime_str+ 2); datetime_str[ 2] = '\0';
|
||||||
gpx->year = atoi(datetime_str) + 2000;
|
gpx->year = atoi(datetime_str) + 2000;
|
||||||
|
|
||||||
|
int pos_BATT = fn(gpx, 4);
|
||||||
|
gpx->batt = atof(gpx->frm_str+pos_BATT);
|
||||||
|
|
||||||
int pos_LAT = fn(gpx, 5);
|
int pos_LAT = fn(gpx, 5);
|
||||||
gpx->lat = atof(gpx->frm_str+pos_LAT);
|
gpx->lat = atof(gpx->frm_str+pos_LAT);
|
||||||
|
|
||||||
|
@ -204,12 +222,28 @@ static int print_frame(gpx_t *gpx, int pos) {
|
||||||
int pos_ALT = fn(gpx, 7);
|
int pos_ALT = fn(gpx, 7);
|
||||||
gpx->alt = atof(gpx->frm_str+pos_ALT);
|
gpx->alt = atof(gpx->frm_str+pos_ALT);
|
||||||
|
|
||||||
|
int pos_VD = fn(gpx, 8); // 0..360 Heading
|
||||||
|
gpx->vD = atof(gpx->frm_str+pos_VD);
|
||||||
|
|
||||||
|
int pos_VH = fn(gpx, 9); // m/s vH
|
||||||
|
gpx->vH = atof(gpx->frm_str+pos_VH);
|
||||||
|
|
||||||
|
int pos_rawT1 = fn(gpx, 11);
|
||||||
|
int pos_rawT2 = fn(gpx, 12);
|
||||||
|
int pos_rawRH = fn(gpx, 13);
|
||||||
|
|
||||||
|
gpx->T = get_Temp(atof(gpx->frm_str+pos_rawT1)); // rawT1==rawT2
|
||||||
|
|
||||||
|
|
||||||
if (gpx->option.vbs) {
|
if (gpx->option.vbs) {
|
||||||
printf(" [%4d] ", gpx->frnr);
|
printf(" [%4d] ", gpx->frnr);
|
||||||
printf(" (%s) ", gpx->ID);
|
printf(" (%s) ", gpx->ID);
|
||||||
printf(" %4d-%02d-%02d ", gpx->year, gpx->month, gpx->day);
|
printf(" %4d-%02d-%02d ", gpx->year, gpx->month, gpx->day);
|
||||||
printf("%02d:%02d:%02d ", gpx->hrs, gpx->min, gpx->sec);
|
printf("%02d:%02d:%02d ", gpx->hrs, gpx->min, gpx->sec);
|
||||||
printf(" lat: %.6f lon: %.6f alt: %.0f ", gpx->lat, gpx->lon, gpx->alt);
|
printf(" lat: %.6f lon: %.6f alt: %.0f ", gpx->lat, gpx->lon, gpx->alt);
|
||||||
|
printf(" vH: %4.1f D: %5.1f ", gpx->vH, gpx->vD);
|
||||||
|
printf(" Vbat:%.1fV ", gpx->batt/1000.0);
|
||||||
|
if (gpx->T > -270.0f) printf(" T=%.1fC ", gpx->T);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +252,10 @@ static int print_frame(gpx_t *gpx, int pos) {
|
||||||
// UTC oder GPS?
|
// UTC oder GPS?
|
||||||
char *ver_jsn = NULL;
|
char *ver_jsn = NULL;
|
||||||
printf("{ \"type\": \"%s\"", "MTS01");
|
printf("{ \"type\": \"%s\"", "MTS01");
|
||||||
printf(", \"frame\": %d, \"id\": \"MTS01-%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f",
|
printf(", \"frame\": %d, \"id\": \"MTS01-%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f",
|
||||||
gpx->frnr, gpx->ID, gpx->year, gpx->month, gpx->day, gpx->hrs, gpx->min, (float)gpx->sec, gpx->lat, gpx->lon, gpx->alt );
|
gpx->frnr, gpx->ID, gpx->year, gpx->month, gpx->day, gpx->hrs, gpx->min, (float)gpx->sec, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD );
|
||||||
|
printf(", \"batt\": %.2f", gpx->batt/1000.0);
|
||||||
|
if (gpx->T > -270.0f) printf(", \"temp\": %.1f", gpx->T);
|
||||||
if (gpx->jsn_freq > 0) {
|
if (gpx->jsn_freq > 0) {
|
||||||
printf(", \"freq\": %d", gpx->jsn_freq);
|
printf(", \"freq\": %d", gpx->jsn_freq);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue