kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
clear all decoded data on ID change, don't leave anything old behind
rodzic
5384d36151
commit
032d8452c6
|
@ -680,6 +680,12 @@ int RS41::decode41(byte *data, int maxlen)
|
|||
switch(typ) {
|
||||
case 'y': // name
|
||||
{
|
||||
if(strncmp(si->id, (const char *)(data+p+2), 8)) {
|
||||
// ID changed, i.e. new sonde on same frequency. clear calibration and all other data
|
||||
sonde.clearAllData(si);
|
||||
struct subframeBuffer *sub = (struct subframeBuffer *)si->extra;
|
||||
if(sub) { sub->valid = 0; }
|
||||
}
|
||||
Serial.print("#");
|
||||
uint16_t fnr = data[p]+(data[p+1]<<8);
|
||||
Serial.print(fnr);
|
||||
|
@ -687,13 +693,8 @@ int RS41::decode41(byte *data, int maxlen)
|
|||
Serial.print("; RS41 ID ");
|
||||
snprintf(buf, 10, "%.8s ", data+p+2);
|
||||
Serial.print(buf);
|
||||
sonde.si()->batteryVoltage = data[p+10] / 10.0f;
|
||||
si->batteryVoltage = data[p+10] / 10.0f;
|
||||
si->type=STYPE_RS41;
|
||||
if(strncmp(si->id, (const char *)(data+p+2), 8)) {
|
||||
// ID changed, i.e. new sonde on same frequency. clear calibration data
|
||||
struct subframeBuffer *sub = (struct subframeBuffer *)si->extra;
|
||||
if(sub) { sub->valid = 0; }
|
||||
}
|
||||
strncpy(si->id, (const char *)(data+p+2), 8);
|
||||
si->id[8]=0;
|
||||
strncpy(si->ser, (const char *)(data+p+2), 8);
|
||||
|
|
|
@ -667,6 +667,14 @@ uint8_t Sonde::updateState(uint8_t event) {
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
void Sonde::clearAllData(SondeInfo *si) {
|
||||
// set everything to 0
|
||||
memset(si->id, 0, offsetof(SondeInfo, extra)-offsetof(SondeInfo, id));
|
||||
// set floats to NaN
|
||||
si->lat = si->lon = si->alt = si->vs = si->hs = si->dir = NAN;
|
||||
si->temperature = si->temRHSensor = si->relativeHumidity = si->batteryVoltage = NAN;
|
||||
}
|
||||
|
||||
void Sonde::updateDisplayPos() {
|
||||
disp.updateDisplayPos();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,13 @@ extern uint8_t debug;
|
|||
|
||||
// RX_TIMEOUT: no header detected
|
||||
// RX_ERROR: header detected, but data not decoded (crc error, etc.)
|
||||
// RX_OK: header and data ok
|
||||
// RX_PARTIAL: header detected, some data ok, some with errors
|
||||
// For RS41: Some blocks with CRC error, some blocks ok in a single frame
|
||||
// For DFM: In +- 1s, some but not all DAT-subframes 1,2,3,4,5,6,7,8 received
|
||||
// For RS92 ??? unclear
|
||||
// For M10/M20 its always all or nothing, no PARTIAL data
|
||||
// For MP3H its alway all or nothing, no PARTIAL data
|
||||
// RX_OK: header and all data ok
|
||||
enum RxResult { RX_OK, RX_TIMEOUT, RX_ERROR, RX_UNKNOWN, RX_NOPOS };
|
||||
#define RX_UPDATERSSI 0xFFFE
|
||||
|
||||
|
@ -69,17 +75,32 @@ extern const char *manufacturer_string[NSondeTypes];
|
|||
#define TYPE_IS_METEO(t) ( (t)==STYPE_M10 || (t)==STYPE_M20 )
|
||||
|
||||
typedef struct st_sondeinfo {
|
||||
// First part: static configuration, not decoded data.
|
||||
// receiver configuration
|
||||
bool active;
|
||||
SondeType type;
|
||||
int8_t subtype; /* 0 for none/unknown, hex type for dfm, 1/2 for M10/M20 */
|
||||
float freq;
|
||||
char launchsite[18];
|
||||
|
||||
// Second part: internal decoder state. no need to clear this on new sonde
|
||||
// RSSI from receiver
|
||||
int rssi; // signal strength
|
||||
int32_t afc; // afc correction value
|
||||
// statistics
|
||||
uint8_t rxStat[20];
|
||||
uint32_t rxStart; // millis() timestamp of continuous rx start
|
||||
uint32_t norxStart; // millis() timestamp of continuous no rx start
|
||||
uint32_t viewStart; // millis() timestamp of viewinf this sonde with current display
|
||||
int8_t lastState; // -1: disabled; 0: norx; 1: rx
|
||||
|
||||
// Third part: decoded data. Clear if reception of a new sonde has started
|
||||
// decoded ID
|
||||
char typestr[5]; // decoded type (use type if *typestr==0)
|
||||
// id must be the start of decoded data, extra indicates the end.
|
||||
char id[10];
|
||||
char ser[12];
|
||||
bool validID;
|
||||
char launchsite[18];
|
||||
char typestr[5]; // decoded type (use type if *typestr==0)
|
||||
int8_t subtype; /* 0 for none/unknown, hex type for dfm, 1/2 for M10/M20 */
|
||||
// decoded position
|
||||
float lat; // latitude
|
||||
float lon; // longitude
|
||||
|
@ -94,24 +115,15 @@ typedef struct st_sondeinfo {
|
|||
uint32_t frame;
|
||||
uint32_t vframe; // vframe==frame if frame is unique/continous, otherweise vframe is derived from gps time
|
||||
bool validTime;
|
||||
// RSSI from receiver
|
||||
int rssi; // signal strength
|
||||
int32_t afc; // afc correction value
|
||||
// statistics
|
||||
uint8_t rxStat[20];
|
||||
uint32_t rxStart; // millis() timestamp of continuous rx start
|
||||
uint32_t norxStart; // millis() timestamp of continuous no rx start
|
||||
uint32_t viewStart; // millis() timestamp of viewinf this sonde with current display
|
||||
int8_t lastState; // -1: disabled; 0: norx; 1: rx
|
||||
// shut down timers, currently only for RS41; -1=disabled
|
||||
uint16_t launchKT, burstKT, countKT;
|
||||
uint16_t crefKT; // frame number in which countKT was last sent
|
||||
// sonde specific extra data, NULL if unused or not yet initialized, currently used for RS41 subframe data (calibration)
|
||||
void *extra;
|
||||
float temperature = -300.0; // platinum resistor temperature
|
||||
float tempRHSensor = -300.0; // temperature of relative humidity sensor
|
||||
float relativeHumidity = -1.0; // relative humidity
|
||||
float batteryVoltage = -1;
|
||||
void *extra;
|
||||
} SondeInfo;
|
||||
// rxStat: 3=undef[empty] 1=timeout[.] 2=errro[E] 0=ok[|] 4=no valid position[°]
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue