kopia lustrzana https://github.com/sp9skp/spdxl
dekodowanie Vbat,temperatur M10, przekazywanie dla RS92,M10 i DFM tych parametrów do bazy
rodzic
c24f74fd3a
commit
693dc1e159
2
VER.txt
2
VER.txt
|
@ -1 +1 @@
|
|||
20180924a
|
||||
20180929
|
287
src/sondemod.c
287
src/sondemod.c
|
@ -320,6 +320,7 @@ struct DBS{
|
|||
double ozon;
|
||||
char aux;
|
||||
double press;
|
||||
float vbat,t1,t2,hum;
|
||||
} dBs[30];
|
||||
|
||||
static FILENAME semfile;
|
||||
|
@ -467,7 +468,7 @@ int save_csv()
|
|||
maxpos=i;
|
||||
}
|
||||
}
|
||||
if(dBs[maxpos].name[0]!=0){
|
||||
if(dBs[maxpos].name[i]!=0){
|
||||
sprintf(str,"%s;%0.5f;%0.5f;%0.0f;%0.2f;%0.2f;%0.0f;%0.3f;%lu\n",dBs[maxpos].name,dBs[maxpos].lat,dBs[maxpos].lon,dBs[maxpos].alt,dBs[maxpos].speed,dBs[maxpos].climb,dBs[maxpos].dir,dBs[maxpos].frq,dBs[maxpos].time);
|
||||
fputs(str,stream);
|
||||
}
|
||||
|
@ -599,7 +600,7 @@ unsigned int passAprs(char *pas){
|
|||
}
|
||||
|
||||
|
||||
void saveMysql( char *name,unsigned int frameno, double lat, double lon, double alt, double speed, double dir, double climb,int typ,char bk, unsigned int swv,double ozon, char aux, double press, float frq){
|
||||
void saveMysql( char *name,unsigned int frameno, double lat, double lon, double alt, double speed, double dir, double climb,int typ,char bk, unsigned int swv,double ozon, char aux, double press, float frq, float vbat, float t1, float t2, float hum){
|
||||
char str[1024];
|
||||
char hash[40];
|
||||
|
||||
|
@ -618,8 +619,8 @@ void saveMysql( char *name,unsigned int frameno, double lat, double lon, double
|
|||
strcpy(Pass,dbPass);
|
||||
str[0]=0;
|
||||
|
||||
sprintf( UDPbuf, "S0;0;0;0;%s;%lf;%lf;%5.1lf;%u;%3.1f;%3.0f;%3.1f;%4.1f;%4.1f;%u;%i;%i;%i;%7.3f;1;2;3;4;%s",
|
||||
name,lat,lon,alt,frameno,speed,dir,climb,press,ozon,swv,bk,typ,aux,frq,mycall);
|
||||
sprintf( UDPbuf, "S0;0;0;0;%s;%lf;%lf;%5.1lf;%u;%3.1f;%3.0f;%3.1f;%4.1f;%4.1f;%u;%i;%i;%i;%7.3f;%3.2f;%3.1f;%3.1f;%3.0f;%s",
|
||||
name,lat,lon,alt,frameno,speed,dir,climb,press,ozon,swv,bk,typ,aux,frq,vbat,t1,t2,hum,mycall);
|
||||
|
||||
//wylicznie hasha
|
||||
strcpy(ToHash,UDPbuf);
|
||||
|
@ -640,7 +641,7 @@ void saveMysql( char *name,unsigned int frameno, double lat, double lon, double
|
|||
|
||||
|
||||
|
||||
int store_sonde_db( char *name,unsigned int frameno, double lat, double lon, double alt, double speed, double dir, double climb,int typ,char bk, unsigned int swv,double ozon, char aux, double press, float frq){
|
||||
int store_sonde_db( char *name,unsigned int frameno, double lat, double lon, double alt, double speed, double dir, double climb,int typ,char bk, unsigned int swv,double ozon, char aux, double press, float frq, float vbat, float t1, float t2, float hum){
|
||||
|
||||
// printf("***** %s\n",name);
|
||||
int i,newS=1;
|
||||
|
@ -656,6 +657,10 @@ int store_sonde_db( char *name,unsigned int frameno, double lat, double lon, dou
|
|||
}
|
||||
}
|
||||
|
||||
if(t1<-250 || t1>80) t1=0;
|
||||
if(t2<-250 || t2>80) t2=0;
|
||||
if(hum<0 || hum>100) hum=0;
|
||||
if(vbat<1 || vbat>40) vbat=0;
|
||||
|
||||
i=0;
|
||||
while(dBs[i].name[0]!=0 && i<30 && soNum<0){
|
||||
|
@ -697,10 +702,14 @@ int store_sonde_db( char *name,unsigned int frameno, double lat, double lon, dou
|
|||
dBs[i].ozon=ozon;
|
||||
dBs[i].aux=aux;
|
||||
dBs[i].press=press;
|
||||
dBs[i].vbat=vbat;
|
||||
dBs[i].t1=t1;
|
||||
dBs[i].t2=t2;
|
||||
dBs[i].hum=hum;
|
||||
|
||||
if(disSKP==0){
|
||||
if(alt<3000 || difftime>14 || newS){
|
||||
saveMysql( name, frameno, dBs[i].lat, dBs[i].lon, alt, speed, dir, climb, typ, bk, swv, ozon, aux, press, frq);
|
||||
saveMysql( name, frameno, dBs[i].lat, dBs[i].lon, alt, speed, dir, climb, typ, bk, swv, ozon, aux, press, frq,vbat,t1,t2,hum);
|
||||
dBs[i].sendtime=time(NULL);
|
||||
}
|
||||
}
|
||||
|
@ -1969,7 +1978,7 @@ static void decodeframe(uint8_t m, uint32_t ip, uint32_t fromport)
|
|||
calperc(anonym1->calibok), 0UL,0.0, sondeaprs_nofilter,"RS92",5,0);
|
||||
anonym1->framesent = 1;
|
||||
//SKP
|
||||
store_sonde_db( objname,frameno,anonym1->lat,anonym1->long0,anonym1->heig,anonym1->speed,anonym1->dir,anonym1->climb,9,2,0,anonym1->ozon,anonym1->aux,anonym1->hp,(double)mhz);
|
||||
store_sonde_db( objname,frameno,anonym1->lat,anonym1->long0,anonym1->heig,anonym1->speed,anonym1->dir,anonym1->climb,9,2,0,anonym1->ozon,anonym1->aux,anonym1->hp,(double)mhz,0,anonym1->temp,0,anonym1->hyg);
|
||||
|
||||
}
|
||||
crdone = 1;
|
||||
|
@ -2486,7 +2495,7 @@ static void decodec34(const char rxb[], uint32_t rxb_len,
|
|||
sondeaprs_nofilter,"C34",4,0);
|
||||
anonym2->lastsent = systime;
|
||||
//SKP
|
||||
store_sonde_db(anonym2->name,0,exlat,exlon,anonym2->alt,anonym2->speed,anonym2->dir,anonym2->clmb,3,2,0,0.0,0,0,frq);
|
||||
store_sonde_db(anonym2->name,0,exlat,exlon,anonym2->alt,anonym2->speed,anonym2->dir,anonym2->clmb,3,2,0,0.0,0,0,frq,0,0,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2520,9 +2529,10 @@ static void decodedfm6(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
char typ[10];
|
||||
int typm=6;
|
||||
|
||||
if ((rxb[0UL]!='D')||((rxb[1UL]=='6') && rxb[1UL]!='9')) return;
|
||||
if ((rxb[0UL]!='D')||( (rxb[1UL]!='6') && (rxb[1UL]!='9') && (rxb[1UL]!='F') )) return;
|
||||
|
||||
if(rxb[1UL]=='9') typm=7;
|
||||
else if(rxb[1UL]=='F') typm=15;
|
||||
|
||||
sprintf(typ,"DFM0%c",rxb[1UL]);
|
||||
tmp[0]=rxb[0]; tmp[1]=rxb[1]; tmp[2]=rxb[2]; tmp[3]=rxb[3]; tmp[4]=rxb[4]; tmp[5]=rxb[5]; tmp[6]=rxb[6];
|
||||
|
@ -2586,7 +2596,6 @@ static void decodedfm6(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
|
||||
getcall(tmp, 6, usercall, 11ul);
|
||||
if (usercall[0U]==0) aprsstr_Assign(usercall, 11ul, mycall, 100ul);
|
||||
// printf("\nDEB: %s:%s\n",usercall,tmp);
|
||||
|
||||
if (sondeaprs_verb && fromport>0UL) {
|
||||
osi_WrStr("UDP:", 5ul);
|
||||
|
@ -2660,7 +2669,7 @@ static void decodedfm6(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
0UL, 0.0, sondeaprs_nofilter,typ,5,Vcc );
|
||||
|
||||
anonym->lastsent = osic_time();
|
||||
store_sonde_db(id+2,0,lat,lon,alt,vH,Dir,vV,typm,2,0,0.0,0,0.0,frq);
|
||||
store_sonde_db(id+2,0,lat,lon,alt,vH,Dir,vV,typm,2,0,0.0,0,0.0,frq,Vcc,T,T1,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2930,7 +2939,6 @@ static void decoders41(const char rxb[], uint32_t rxb_len,
|
|||
getcall(rxb, rxb_len, usercall, 11ul);
|
||||
if (usercall[0U]==0) aprsstr_Assign(usercall, 11ul, mycall, 100ul);
|
||||
|
||||
printf("\nDEB: %s:%s\n",usercall,mycall);
|
||||
if (sondeaprs_verb && fromport>0UL) {
|
||||
osi_WrStr("UDP:", 5ul);
|
||||
aprsstr_ipv4tostr(ip, s, 1001ul);
|
||||
|
@ -3218,7 +3226,7 @@ static void decoders41(const char rxb[], uint32_t rxb_len,
|
|||
sondeaprs_nofilter,"RS41",5,0);
|
||||
pc->framesent = 1;
|
||||
//SKP
|
||||
store_sonde_db( pc->name,frameno,lat,long0,heig,speed,dir,climb,4,pc->burstKill,pc->swVersion,pc->ozonval,pc->aux,0.0,(double)pc->mhz0);
|
||||
store_sonde_db( pc->name,frameno,lat,long0,heig,speed,dir,climb,4,pc->burstKill,pc->swVersion,pc->ozonval,pc->aux,0.0,(double)pc->mhz0,0,0,0,0);
|
||||
|
||||
}
|
||||
/* IF verb THEN WrStrLn("") END; */
|
||||
|
@ -3226,74 +3234,32 @@ static void decoders41(const char rxb[], uint32_t rxb_len,
|
|||
|
||||
/*------------------------------ M10 */
|
||||
|
||||
static uint16_t crcm10(int32_t from, int32_t len, const char buf[],
|
||||
uint32_t buf_len)
|
||||
{
|
||||
int32_t i;
|
||||
uint16_t s;
|
||||
uint16_t t;
|
||||
uint16_t b;
|
||||
uint16_t cs;
|
||||
int32_t tmp;
|
||||
cs = 0U;
|
||||
tmp = (from+len)-1L;
|
||||
i = from;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
/*WrHex(ORD(buf[i]), 3); */
|
||||
b = (uint16_t)(uint32_t)(uint8_t)buf[i];
|
||||
b = X2C_LSH(b,16,-1)|X2C_LSH(b&0x1U,16,7);
|
||||
b = b^X2C_LSH(b,16,-2)&0xFFU;
|
||||
t = cs&0x3FU|X2C_LSH((cs^X2C_LSH(cs,16,-2)^X2C_LSH(cs,16,-4))&0x1U,16,
|
||||
6)|X2C_LSH((X2C_LSH(cs,16,-1)^X2C_LSH(cs,16,-3)^X2C_LSH(cs,
|
||||
16,-5))&0x1U,16,7);
|
||||
s = X2C_LSH(cs,16,-7)&0xFFU;
|
||||
s = (s^X2C_LSH(s,16,-2))&0xFFU;
|
||||
cs = X2C_LSH(cs&0xFFU,16,8)|b^t^s;
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
return (uint16_t)cs;
|
||||
} /* end crcm10() */
|
||||
int isNDig(char *txt){
|
||||
int len,i;
|
||||
int ret=0;
|
||||
len=strlen(txt);
|
||||
if(len==0) return(1);
|
||||
|
||||
for(i=0;i<len;i++){
|
||||
if(txt[i]<47 || txt[i]>57){
|
||||
if(txt[i]!='.' && txt[i]!='-' && txt[i]!=' ')
|
||||
ret=1;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static uint32_t m10card(const char b[], uint32_t b_len,
|
||||
int32_t pos, int32_t len)
|
||||
{
|
||||
int32_t i;
|
||||
uint32_t n;
|
||||
int32_t tmp;
|
||||
n = 0UL;
|
||||
tmp = len-1L;
|
||||
i = 0L;
|
||||
if (i<=tmp) for (;; i++) {
|
||||
n = n*256UL+(uint32_t)(uint8_t)b[pos+i];
|
||||
if (i==tmp) break;
|
||||
} /* end for */
|
||||
return n;
|
||||
} /* end m10card() */
|
||||
|
||||
#define sondemod_FH 16
|
||||
/* size of header before payload */
|
||||
|
||||
static float sondemod_DEGMUL = 8.3819036711397E-8f;
|
||||
|
||||
#define sondemod_VMUL 0.005
|
||||
|
||||
static void decodem10(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t fromport)
|
||||
{
|
||||
uint32_t week;
|
||||
uint32_t tow;
|
||||
uint32_t cs;
|
||||
uint32_t i;
|
||||
int32_t ci;
|
||||
double dir;
|
||||
double fq555;
|
||||
double v;
|
||||
double vv;
|
||||
double vn;
|
||||
double ve;
|
||||
double alt;
|
||||
double lon;
|
||||
double lat;
|
||||
uint32_t time0;
|
||||
char nam[15];
|
||||
char s[1001];
|
||||
CALLSSID usercall;
|
||||
|
@ -3310,22 +3276,20 @@ static void decodem10(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
lon = 0.0;
|
||||
double frq;
|
||||
char tmps[15];
|
||||
|
||||
// for(i=0;i<123;i++)
|
||||
// printf("%c",rxb[i]);
|
||||
// printf("\r\n");
|
||||
tmps[0]=rxb[118];
|
||||
tmps[1]=rxb[119];
|
||||
tmps[2]=rxb[120];
|
||||
tmps[3]='.';
|
||||
tmps[4]=rxb[121];
|
||||
tmps[5]=rxb[122];
|
||||
tmps[6]=rxb[123];
|
||||
tmps[7]=0;
|
||||
frq=atof(tmps);
|
||||
float vbat,temp1,temp2;
|
||||
char to[1200];
|
||||
uint32_t time0;
|
||||
|
||||
getcall(rxb, rxb_len, usercall, 11ul);
|
||||
if (usercall[0U]==0) aprsstr_Assign(usercall, 11ul, mycall, 100ul);
|
||||
|
||||
int cnt=0;
|
||||
for (i=0; i<105; i++)
|
||||
cnt += (rxb[i] == ',');
|
||||
if(cnt!=13) return;
|
||||
|
||||
char *tmp = strtok(rxb, ",");
|
||||
|
||||
getcall(tmp, 6, usercall, 11ul);
|
||||
if (usercall[0U]==0) aprsstr_Assign(usercall, 11ul, mycall, 100ul);
|
||||
|
||||
if (sondeaprs_verb && fromport>0UL) {
|
||||
osi_WrStr("UDP:", 5ul);
|
||||
|
@ -3341,23 +3305,94 @@ static void decodem10(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
osi_WrStrLn("", 1ul);
|
||||
}
|
||||
if (sondeaprs_verb) osi_WrStr("M10 ", 5ul);
|
||||
cs = (uint32_t)crcm10(16L, 100L, rxb, rxb_len);
|
||||
if (cs==m10card(rxb, rxb_len, 116L, 2L)) {
|
||||
|
||||
/* crc ok */
|
||||
nameok = 1;
|
||||
for (i = 0UL; i<=8UL; i++) {
|
||||
nam[i] = rxb[7UL+i];
|
||||
if ((uint8_t)nam[i]<=' ' || (uint8_t)nam[i]>'Z') nameok = 0;
|
||||
} /* end for */
|
||||
nam[9U] = 0;
|
||||
tmp = strtok(NULL, ","); //frq
|
||||
if(isNDig(tmp)) return(0);
|
||||
frq=atof(tmp)/1000;
|
||||
|
||||
tmp = strtok(NULL, ","); //nazwa
|
||||
if(isNDig(tmp)) return(0);
|
||||
strcpy(nam,tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //time
|
||||
if(isNDig(tmp)) return(0);
|
||||
time0=atol(tmp);
|
||||
frameno=time0;
|
||||
|
||||
tmp = strtok(NULL, ","); //lat
|
||||
if(isNDig(tmp)) return(0);
|
||||
lat=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //lon
|
||||
if(isNDig(tmp)) return(0);
|
||||
lon=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //alt
|
||||
if(isNDig(tmp)) return(0);
|
||||
alt=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //dir
|
||||
if(isNDig(tmp)) return(0);
|
||||
dir=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //v
|
||||
if(isNDig(tmp)) return(0);
|
||||
v=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //vv
|
||||
if(isNDig(tmp)) return(0);
|
||||
vv=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //vbat
|
||||
if(isNDig(tmp)) return(0);
|
||||
vbat=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //temp1
|
||||
if(isNDig(tmp)) return(0);
|
||||
temp1=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //temp2
|
||||
if(isNDig(tmp)) return(0);
|
||||
temp2=atof(tmp);
|
||||
|
||||
tmp = strtok(NULL, ","); //fq555
|
||||
if(isNDig(tmp)) return(0);
|
||||
fq555=atof(tmp);
|
||||
|
||||
if (sondeaprs_verb) {
|
||||
osi_WrStr(nam, 10ul);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrINT32(frameno, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrFixed((float)lat, 5L, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrFixed((float)lon, 5L, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrFixed((float)alt, 1L, 1UL);
|
||||
osi_WrStr("m ", 3ul);
|
||||
osic_WrFixed((float)(v*3.6), 1L, 1UL);
|
||||
osi_WrStr("km/h ", 6ul);
|
||||
osic_WrFixed((float)dir, 0L, 1UL);
|
||||
osi_WrStr("deg ", 5ul);
|
||||
osic_WrFixed((float)vv, 1L, 1UL);
|
||||
osi_WrStr("m/s ", 5ul);
|
||||
osic_WrFixed((float)vbat, 1L, 1UL);
|
||||
osi_WrStr("V ", 3ul);
|
||||
osic_WrFixed((float)temp1, 1L, 1UL);
|
||||
osi_WrStr("C ", 3ul);
|
||||
osic_WrFixed((float)temp2, 1L, 1UL);
|
||||
osi_WrStr("C ", 3ul);
|
||||
|
||||
|
||||
}
|
||||
|
||||
pc = pcontextm10;
|
||||
pc0 = 0;
|
||||
for (;;) {
|
||||
if (pc==0) break;
|
||||
pc1 = pc->next;
|
||||
if (pc->tused+3600UL<systime) {
|
||||
/* timed out */
|
||||
|
||||
if (pc0==0) pcontextm10 = pc1;
|
||||
else pc0->next = pc1;
|
||||
osic_free((char * *) &pc, sizeof(struct CONTEXTM10));
|
||||
|
@ -3377,13 +3412,10 @@ static void decodem10(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
aprsstr_Assign(pc->name, 10ul, nam, 10ul);
|
||||
if (sondeaprs_verb) osi_WrStrLn("is new ", 8ul);
|
||||
}
|
||||
tow = m10card(rxb, rxb_len, 27L, 4L);
|
||||
week = m10card(rxb, rxb_len, 49L, 2L);
|
||||
time0 = tow/1000UL+week*604800UL+315964800UL;
|
||||
|
||||
frameno = time0;
|
||||
pc->gpssecond = time0+86382UL;
|
||||
if (frameno>pc->framenum) {
|
||||
/* new frame number */
|
||||
pc->framesent = 0;
|
||||
calok = 1;
|
||||
pc->framenum = frameno;
|
||||
|
@ -3399,53 +3431,22 @@ static void decodem10(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
osic_WrINT32(pc->framenum, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
}
|
||||
lat = (double)m10card(rxb, rxb_len, 31L, 4L)*8.3819036711397E-8;
|
||||
lon = (double)m10card(rxb, rxb_len, 35L, 4L)*8.3819036711397E-8;
|
||||
alt = (double)m10card(rxb, rxb_len, 39L, 4L)*0.001;
|
||||
ci = (int32_t)m10card(rxb, rxb_len, 21L, 2L);
|
||||
if (ci>32767L) ci -= 65536L;
|
||||
ve = (double)ci*0.005;
|
||||
ci = (int32_t)m10card(rxb, rxb_len, 23L, 2L);
|
||||
if (ci>32767L) ci -= 65536L;
|
||||
vn = (double)ci*0.005;
|
||||
ci = (int32_t)m10card(rxb, rxb_len, 25L, 2L);
|
||||
if (ci>32767L) ci -= 65536L;
|
||||
vv = (double)ci*0.005;
|
||||
v = (double)osic_sqrt((float)(ve*ve+vn*vn)); /* hor speed */
|
||||
dir = atan20(vn, ve)*5.7295779513082E+1;
|
||||
if (dir<0.0) dir = 360.0+dir;
|
||||
if (sondeaprs_verb) {
|
||||
osi_WrStr(nam, 10ul);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrINT32(frameno, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrFixed((float)lat, 5L, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrFixed((float)lon, 5L, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
osic_WrFixed((float)alt, 1L, 1UL);
|
||||
osi_WrStr("m ", 3ul);
|
||||
osic_WrFixed((float)(v*3.6), 1L, 1UL);
|
||||
osi_WrStr("km/h ", 6ul);
|
||||
osic_WrFixed((float)dir, 0L, 1UL);
|
||||
osi_WrStr("deg ", 5ul);
|
||||
osic_WrFixed((float)vv, 1L, 1UL);
|
||||
osi_WrStr("m/s ", 5ul);
|
||||
}
|
||||
}
|
||||
else if (sondeaprs_verb) osi_WrStr("crc error", 10ul);
|
||||
if (sondeaprs_verb) osi_WrStrLn("", 1ul);
|
||||
if ((((pc && nameok) && calok) && lat!=0.0) && lon!=0.0) {
|
||||
sondeaprs_senddata(lat*1.7453292519943E-2, lon*1.7453292519943E-2, alt, v, dir, vv, 0.0, 0.0,
|
||||
|
||||
|
||||
if (pc && lat>0 && lat<90 && lon>0 && lat<45000 ) {
|
||||
|
||||
//printf("M10: (%s) %s,%012lu,%09.5f,%010.5f,%05.0f,%03.0f,%05.1f,%05.1f,%05.2f,%06.1f,%06.1f,%06.0f\n",usercall,nam,time0,lat,lon,alt,dir,v,vv,vbat,temp1,temp2,fq555);
|
||||
sondeaprs_senddata(lat*1.7453292519943E-2, lon* 1.7453292519943E-2, alt, v, dir, vv, 0.0, 0.0,
|
||||
(double)X2C_max_real, 0.0, 0.0, 0.0, 0.0, frq, 0.0, 0.0,
|
||||
pc->gpssecond, pc->framenum, pc->name, 9ul, 0UL, 0, usercall,
|
||||
pc->gpssecond, pc->framenum, pc->name, 9ul, 0UL, 0, usercall,
|
||||
11ul, 0UL, 0UL,0, sondeaprs_nofilter,"M10",4,0);
|
||||
|
||||
store_sonde_db( pc->name,pc->framenum,lat*1.7453292519943E-2,lon*1.7453292519943E-2,alt,v,dir,vv,1,0,0,0,0,0.0,frq);
|
||||
|
||||
|
||||
store_sonde_db( pc->name,pc->framenum,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,v,dir,vv,1,0,0,0,0,0.0,frq,vbat,temp1,temp2,fq555);
|
||||
pc->framesent = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} /* end decodem10() */
|
||||
|
||||
|
||||
|
@ -3726,7 +3727,7 @@ static void decodepils(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
gpstime, 0.0, pc->name, 9ul, 0UL, pgoodsat, usercall,
|
||||
11ul, 0UL, 0UL,0, sondeaprs_nofilter,"PilS",5,0);
|
||||
|
||||
store_sonde_db( pc->name,0,lat,long0,heig,speed,dir,climb,8,0,0,0,0,0.0,frq);
|
||||
store_sonde_db( pc->name,0,lat,long0,heig,speed,dir,climb,8,0,0,0,0,0.0,frq,0,0,0,0);
|
||||
|
||||
pc->framesent = 1;
|
||||
}
|
||||
|
@ -3770,7 +3771,7 @@ static void udprx(void)
|
|||
else if (len==520L) {
|
||||
decoders41(chan[sondemod_LEFT].rxbuf, 520ul, ip, fromport);
|
||||
}
|
||||
else if (len==117L+7L) {
|
||||
else if (len==105) {
|
||||
decodem10(chan[sondemod_LEFT].rxbuf, 520ul, ip, fromport);
|
||||
}
|
||||
else if (len==55L+6L) {
|
||||
|
|
342
src/sondeudp.c
342
src/sondeudp.c
|
@ -276,6 +276,7 @@ struct DFM6 {
|
|||
int sonde_typ;
|
||||
uint32_t SN6;
|
||||
uint32_t SN9;
|
||||
uint32_t SN15;
|
||||
int yr; int mon; int day;
|
||||
int hr; int min; float sek;
|
||||
double lat; double lon; double alt;
|
||||
|
@ -1607,6 +1608,160 @@ static void WrChan(int32_t c)
|
|||
|
||||
|
||||
|
||||
// Temperatur Sensor
|
||||
// NTC-Thermistor Shibaura PB5-41E
|
||||
//
|
||||
float M10get_Temp(uint32_t m) {
|
||||
// NTC-Thermistor Shibaura PB5-41E
|
||||
// T00 = 273.15 + 0.0 , R00 = 15e3
|
||||
// T25 = 273.15 + 25.0 , R25 = 5.369e3
|
||||
// B00 = 3450.0 Kelvin // 0C..100C, poor fit low temps
|
||||
// [ T/C , R/1e3 ] ( [P__-43]/2.0 ):
|
||||
// [ -50.0 , 204.0 ]
|
||||
// [ -45.0 , 150.7 ]
|
||||
// [ -40.0 , 112.6 ]
|
||||
// [ -35.0 , 84.90 ]
|
||||
// [ -30.0 , 64.65 ]
|
||||
// [ -25.0 , 49.66 ]
|
||||
// [ -20.0 , 38.48 ]
|
||||
// [ -15.0 , 30.06 ]
|
||||
// [ -10.0 , 23.67 ]
|
||||
// [ -5.0 , 18.78 ]
|
||||
// [ 0.0 , 15.00 ]
|
||||
// [ 5.0 , 12.06 ]
|
||||
// [ 10.0 , 9.765 ]
|
||||
// [ 15.0 , 7.955 ]
|
||||
// [ 20.0 , 6.515 ]
|
||||
// [ 25.0 , 5.370 ]
|
||||
// [ 30.0 , 4.448 ]
|
||||
// [ 35.0 , 3.704 ]
|
||||
// [ 40.0 , 3.100 ]
|
||||
// -> Steinhart–Hart coefficients (polyfit):
|
||||
float p0 = 1.07303516e-03,
|
||||
p1 = 2.41296733e-04,
|
||||
p2 = 2.26744154e-06,
|
||||
p3 = 6.52855181e-08;
|
||||
// T/K = 1/( p0 + p1*ln(R) + p2*ln(R)^2 + p3*ln(R)^3 )
|
||||
|
||||
// range/scale 0, 1, 2: // M10-pcb
|
||||
float Rs[3] = { 12.1e3 , 36.5e3 , 475.0e3 }; // bias/series
|
||||
float Rp[3] = { 1e20 , 330.0e3 , 3000.0e3 }; // parallel, Rp[0]=inf
|
||||
|
||||
uint8_t scT; // {0,1,2}, range/scale voltage divider
|
||||
uint16_t ADC_RT; // ADC12 P6.7(A7) , adr_0377h,adr_0376h
|
||||
uint16_t Tcal[2]; // adr_1000h[scT*4]
|
||||
|
||||
float adc_max = 4095.0; // ADC12
|
||||
float x, R;
|
||||
float T = 0; // T/Kelvin
|
||||
|
||||
struct M10 * anonym = &chan[m].m10;
|
||||
|
||||
scT = (unsigned char)anonym->rxbuf[0x3E]; // adr_0455h
|
||||
ADC_RT = ((unsigned char)anonym->rxbuf[0x40] << 8) | (unsigned char)anonym->rxbuf[0x3F];
|
||||
ADC_RT -= 0xA000;
|
||||
Tcal[0] = ((unsigned char)anonym->rxbuf[0x42] << 8) | (unsigned char)anonym->rxbuf[0x41];
|
||||
Tcal[1] = ((unsigned char)anonym->rxbuf[0x44] << 8) | (unsigned char)anonym->rxbuf[0x43];
|
||||
|
||||
x = (adc_max-ADC_RT)/ADC_RT; // (Vcc-Vout)/Vout
|
||||
if (scT < 3) R = Rs[scT] /( x - Rs[scT]/Rp[scT] );
|
||||
else R = -1;
|
||||
|
||||
if (R > 0) T = 1/( p0 + p1*log(R) + p2*log(R)*log(R) + p3*log(R)*log(R)*log(R) );
|
||||
/*
|
||||
// if (option_verbose >= 3 && csO) { // on-chip temperature
|
||||
uint16_t ADC_Ti_raw = (anonym->rxbuf[0x49] << 8) | anonym->rxbuf[0x48]; // int.temp.diode, ref: 4095->1.5V
|
||||
float vti, ti;
|
||||
// INCH1A (temp.diode), slau144
|
||||
vti = ADC_Ti_raw/4095.0 * 1.5; // V_REF+ = 1.5V, no calibration
|
||||
ti = (vti-0.986)/0.00355; // 0.986/0.00355=277.75, 1.5/4095/0.00355=0.1032
|
||||
fprintf(stdout, " (Ti:%.1fC)", ti);
|
||||
// SegmentA-Calibration:
|
||||
//ui16_t T30 = adr_10e2h; // CAL_ADC_15T30
|
||||
//ui16_t T85 = adr_10e4h; // CAL_ADC_15T85
|
||||
//float tic = (ADC_Ti_raw-T30)*(85.0-30.0)/(T85-T30) + 30.0;
|
||||
//fprintf(stdout, " (Tic:%.1fC)", tic);
|
||||
// }
|
||||
*/
|
||||
return T - 273.15; // Celsius
|
||||
}
|
||||
/*
|
||||
frame[0x32]: adr_1074h
|
||||
frame[0x33]: adr_1075h
|
||||
frame[0x34]: adr_1076h
|
||||
frame[0x35..0x37]: TBCCR1 ; relHumCap-freq
|
||||
frame[0x38]: adr_1078h
|
||||
frame[0x39]: adr_1079h
|
||||
frame[0x3A]: adr_1077h
|
||||
frame[0x3B]: adr_100Ch
|
||||
frame[0x3C..3D]: 0
|
||||
frame[0x3E]: scale_index ; scale/range-index
|
||||
frame[0x3F..40] = ADC12_A7 | 0xA000, V_R+=AVcc ; Thermistor
|
||||
frame[0x41]: adr_1000h[scale_index*4]
|
||||
frame[0x42]: adr_1000h[scale_index*4+1]
|
||||
frame[0x43]: adr_1000h[scale_index*4+2]
|
||||
frame[0x44]: adr_1000h[scale_index*4+3]
|
||||
frame[0x45..46]: ADC12_A5/4, V_R+=2.5V
|
||||
frame[0x47]: ADC12_A2/16 , V_R+=2.5V
|
||||
frame[0x48..49]: ADC12_iT, V_R+=1.5V (int.Temp.diode)
|
||||
frame[0x4C..4D]: ADC12_A6, V_R+=2.5V
|
||||
frame[0x4E..4F]: ADC12_A3, V_R+=AVcc
|
||||
frame[0x50..54]: 0;
|
||||
frame[0x55..56]: ADC12_A1, V_R+=AVcc
|
||||
frame[0x57..58]: ADC12_A0, V_R+=AVcc
|
||||
frame[0x59..5A]: ADC12_A4, V_R+=AVcc // ntc2: R(25C)=2.2k, Rs=22.1e3 (relHumCap-Temp)
|
||||
frame[0x5B]:
|
||||
frame[0x5C]: adr_108Eh
|
||||
frame[0x5D]: adr_1082h (SN)
|
||||
frame[0x5E]: adr_1083h (SN)
|
||||
frame[0x5F]: adr_1084h (SN)
|
||||
frame[0x60]: adr_1080h (SN)
|
||||
frame[0x61]: adr_1081h (SN)
|
||||
*/
|
||||
float M10get_Tntc2(uint32_t m) {
|
||||
// SMD ntc
|
||||
float Rs = 22.1e3; // P5.6=Vcc
|
||||
// float R25 = 2.2e3;
|
||||
// float b = 3650.0; // B/Kelvin
|
||||
// float T25 = 25.0 + 273.15; // T0=25C, R0=R25=5k
|
||||
// -> Steinhart–Hart coefficients (polyfit):
|
||||
float p0 = 4.42606809e-03,
|
||||
p1 = -6.58184309e-04,
|
||||
p2 = 8.95735557e-05,
|
||||
p3 = -2.84347503e-06;
|
||||
float T = 0.0; // T/Kelvin
|
||||
uint16_t ADC_ntc2; // ADC12 P6.4(A4)
|
||||
float x, R;
|
||||
struct M10 * anonym = &chan[m].m10;
|
||||
|
||||
// if (csOK)
|
||||
// {
|
||||
ADC_ntc2 = ((unsigned char)anonym->rxbuf[0x5A] << 8) | (unsigned char)anonym->rxbuf[0x59];
|
||||
x = (4095.0 - ADC_ntc2)/ADC_ntc2; // (Vcc-Vout)/Vout
|
||||
R = Rs / x;
|
||||
//if (R > 0) T = 1/(1/T25 + 1/b * log(R/R25));
|
||||
if (R > 0) T = 1/( p0 + p1*log(R) + p2*log(R)*log(R) + p3*log(R)*log(R)*log(R) );
|
||||
// }
|
||||
return T - 273.15;
|
||||
}
|
||||
|
||||
// Humidity Sensor
|
||||
// U.P.S.I.
|
||||
//
|
||||
#define FREQ_CAPCLK (8e6/2) // 8 MHz XT2 crystal, InputDivider IDx=01 (/2)
|
||||
#define LN2 0.693147181
|
||||
#define ADR_108A 1000.0 // 0x3E8=1000
|
||||
|
||||
float get_count_RH(uint32_t m) { // capture 1000 rising edges
|
||||
struct M10 * anonym = &chan[m].m10;
|
||||
uint32_t TBCCR1_1000 = anonym->rxbuf[0x35] | (anonym->rxbuf[0x36]<<8) | (anonym->rxbuf[0x37]<<16);
|
||||
return TBCCR1_1000 / ADR_108A;
|
||||
}
|
||||
float get_TLC555freq(uint32_t m) {
|
||||
return FREQ_CAPCLK / get_count_RH(m);
|
||||
}
|
||||
|
||||
|
||||
static void decodeframe10(uint32_t m)
|
||||
{
|
||||
uint32_t week;
|
||||
|
@ -1622,10 +1777,13 @@ static void decodeframe10(uint32_t m)
|
|||
double alt;
|
||||
double lon;
|
||||
double lat;
|
||||
float vbat;
|
||||
float temp1,temp2;
|
||||
uint32_t time0;
|
||||
uint32_t id;
|
||||
char ids[201];
|
||||
char s[201+6];
|
||||
//char s[201+6];
|
||||
char s[400];
|
||||
struct M10 * anonym;
|
||||
struct CHAN * anonym0; /* call if set */
|
||||
{ /* with */
|
||||
|
@ -1633,6 +1791,7 @@ static void decodeframe10(uint32_t m)
|
|||
cs = (uint32_t)crcm10(99L, anonym->rxbuf, 101ul);
|
||||
if (cs==m10card(anonym->rxbuf, 101ul, 99L, 2L)) {
|
||||
/* crc ok */
|
||||
|
||||
tow = m10card(anonym->rxbuf, 101ul, 10L, 4L);
|
||||
week = m10card(anonym->rxbuf, 101ul, 32L, 2L);
|
||||
time0 = tow/1000UL+week*604800UL+315964800UL;
|
||||
|
@ -1641,11 +1800,13 @@ static void decodeframe10(uint32_t m)
|
|||
aprsstr_DateToStr(time0, s, 201ul);
|
||||
osi_WrStr(s, 201ul);
|
||||
osi_WrStr(" ", 2ul);
|
||||
}
|
||||
lat = (double)m10card(anonym->rxbuf, 101ul, 14L,
|
||||
4L)*8.3819036711397E-8;
|
||||
lon = (double)m10card(anonym->rxbuf, 101ul, 18L,
|
||||
4L)*8.3819036711397E-8;
|
||||
}
|
||||
temp1=M10get_Temp(m);
|
||||
temp2=M10get_Tntc2(m);
|
||||
float fq555 = get_TLC555freq(m);
|
||||
vbat=(float)((256*(unsigned char)anonym->rxbuf[70]+(unsigned char)anonym->rxbuf[69])*0.00668);
|
||||
lat = (double)m10card(anonym->rxbuf, 101ul, 14L,4L)*8.3819036711397E-8;
|
||||
lon = (double)m10card(anonym->rxbuf, 101ul, 18L,4L)*8.3819036711397E-8;
|
||||
alt = (double)m10card(anonym->rxbuf, 101ul, 22L, 4L)*0.001;
|
||||
ci = (int32_t)m10card(anonym->rxbuf, 101ul, 4L, 2L);
|
||||
if (ci>32767L) ci -= 65536L;
|
||||
|
@ -1657,11 +1818,12 @@ static void decodeframe10(uint32_t m)
|
|||
if (ci>32767L) ci -= 65536L;
|
||||
vv = (double)ci*0.005;
|
||||
v = (double)osic_sqrt((float)(ve*ve+vn*vn));
|
||||
/* hor speed */
|
||||
// hor speed
|
||||
dir = atang2(vn, ve)*5.7295779513082E+1;
|
||||
if (dir<0.0) dir = 360.0+dir;
|
||||
|
||||
|
||||
|
||||
int i,j,k,l;
|
||||
unsigned int byte;
|
||||
unsigned char sn_bytes[5];
|
||||
|
@ -1674,6 +1836,8 @@ static void decodeframe10(uint32_t m)
|
|||
sn_bytes[i] = byte;
|
||||
}
|
||||
|
||||
printf("%02x:%02x ",(unsigned char)anonym->rxbuf[70],(unsigned char)anonym->rxbuf[69]);
|
||||
|
||||
byte = sn_bytes[2];
|
||||
sprintf(SN, "%1X%02u", (byte>>4)&0xF, byte&0xF);
|
||||
j=atoi(SN);
|
||||
|
@ -1682,8 +1846,8 @@ static void decodeframe10(uint32_t m)
|
|||
byte = sn_bytes[3] | (sn_bytes[4]<<8);
|
||||
sprintf(SN+3, "%1X%1u%04u", sn_bytes[0]&0xF, (byte>>13)&0x7, byte&0x1FFF);
|
||||
sprintf(ids,SN);
|
||||
|
||||
ids[9U] = 0;
|
||||
ids[9U] = 0;
|
||||
|
||||
/* get ID */
|
||||
if (verb) {
|
||||
WrChan((int32_t)m);
|
||||
|
@ -1702,36 +1866,33 @@ static void decodeframe10(uint32_t m)
|
|||
osi_WrStr("deg ", 5ul);
|
||||
osic_WrFixed((float)vv, 1L, 1UL);
|
||||
osi_WrStr("m/s ", 5ul);
|
||||
osic_WrFixed((float)vbat, 1L, 1UL);
|
||||
osi_WrStr("V T1:", 6ul);
|
||||
osic_WrFixed((float)temp1, 1L, 1UL);
|
||||
osi_WrStr("C T2:", 6ul);
|
||||
osic_WrFixed((float)temp2, 1L, 1UL);
|
||||
osi_WrStr("C ", 3ul);
|
||||
}
|
||||
/* build tx frame */
|
||||
for (i = 0UL; i<=9UL; i++) {
|
||||
s[i+7UL] = ids[i];
|
||||
} /* end for */
|
||||
{ /* with */
|
||||
struct CHAN * anonym0 = &chan[m];
|
||||
s[0U] = (char)(anonym0->mycallc/16777216UL);
|
||||
s[1U] = (char)(anonym0->mycallc/65536UL&255UL);
|
||||
s[2U] = (char)(anonym0->mycallc/256UL&255UL);
|
||||
s[3U] = (char)(anonym0->mycallc&255UL);
|
||||
if (anonym0->mycallc>0UL) s[4U] = anonym0->myssid;
|
||||
else s[4U] = '\020';
|
||||
s[5U] = 0;
|
||||
s[6U] = 0;
|
||||
}
|
||||
for (i = 0UL; i<=100UL; i++) {
|
||||
s[i+17UL] = anonym->rxbuf[i]; /* payload */
|
||||
} /* end for */
|
||||
|
||||
|
||||
s[118U] = chan[m].freq[0];
|
||||
s[119U] = chan[m].freq[1];
|
||||
s[120U] = chan[m].freq[2];
|
||||
s[121U] = chan[m].freq[3];
|
||||
s[122U] = chan[m].freq[4];
|
||||
s[123U] = chan[m].freq[5];
|
||||
|
||||
|
||||
alludp(chan[m].udptx, 117UL+7, s, 201ul);
|
||||
struct CHAN * anonym0 = &chan[m];
|
||||
s[0U] = (char)(anonym0->mycallc/16777216UL);
|
||||
s[1U] = (char)(anonym0->mycallc/65536UL&255UL);
|
||||
s[2U] = (char)(anonym0->mycallc/256UL&255UL);
|
||||
s[3U] = (char)(anonym0->mycallc&255UL);
|
||||
if (anonym0->mycallc>0UL) s[4U] = anonym0->myssid;
|
||||
else s[4U] = '\020';
|
||||
s[5]=',';
|
||||
for(i=0;i<6;i++) //qrg
|
||||
s[i+6]=chan[m].freq[i];
|
||||
s[12]=',';
|
||||
for(i=0;i<9;i++) //nazwa
|
||||
s[i+13]=ids[i];
|
||||
s[22]=0;
|
||||
if( lat>-90.0 && lat<90.0 && lon>=-180.0 && lon<=180.0 && alt>0.0 && alt<45000.0 && dir>=0 && dir<361 && v>=0 && v<600 &&
|
||||
vv>-200 && vv<200 && vbat>0 && vbat<10 && temp1>-270.0 && temp1<100.0 && temp2>-270.0 && temp2<100.0){
|
||||
sprintf(s,"%s,%012lu,%09.5f,%010.5f,%05.0f,%03.0f,%05.1f,%05.1f,%05.2f,%06.1f,%06.1f,%06.0f\n",s,time0,lat,lon,alt,dir,v,vv,vbat,temp1,temp2,fq555);
|
||||
// printf("\nM10T:%s",s);
|
||||
alludp(chan[m].udptx, 105, s, 105);
|
||||
}
|
||||
}
|
||||
else if (verb) {
|
||||
/*build tx frame */
|
||||
|
@ -2898,7 +3059,7 @@ static void FskPS(uint32_t m)
|
|||
float ff;
|
||||
int32_t lim;
|
||||
struct PILS * anonym;
|
||||
{ /* with */
|
||||
{
|
||||
struct PILS * anonym = &chan[m].pils;
|
||||
lim = (int32_t)anonym->demodbaud;
|
||||
for (;;) {
|
||||
|
@ -2912,7 +3073,8 @@ static void FskPS(uint32_t m)
|
|||
if (anonym->baudfine<131072L) break;
|
||||
}
|
||||
}
|
||||
} /* end Fsk() */
|
||||
} // end Fsk()
|
||||
|
||||
|
||||
static void Fsk10(uint32_t m)
|
||||
{
|
||||
|
@ -2975,8 +3137,7 @@ static char hamcorr(char b[], uint32_t b_len, uint32_t d,
|
|||
} /* end hamcorr() */
|
||||
|
||||
|
||||
static char hamming(const char b[], uint32_t b_len,
|
||||
uint32_t len, char db[], uint32_t db_len)
|
||||
static char hamming(const char b[], uint32_t b_len, uint32_t len, char db[], uint32_t db_len)
|
||||
{
|
||||
uint32_t j;
|
||||
uint32_t i;
|
||||
|
@ -3306,32 +3467,72 @@ float get_Temp2(float *meas) { // meas[0..4]
|
|||
R = (f-f1)/g; // meas[0,3,4] > 0 ?
|
||||
if (R > 0) T = 1/(1/T0 + 1/BB0 * log(R/R0));
|
||||
|
||||
// if (option_ptu && option_verbose == 2) {
|
||||
printf(" (Rso: %.1f , Rb: %.1f)", Rs_o/1e3, Rb/1e3);
|
||||
// }
|
||||
//printf(" (Rso: %.1f , Rb: %.1f)", Rs_o/1e3, Rb/1e3);
|
||||
|
||||
return T - 273.15;
|
||||
// DFM-06: meas20 * 16 = meas24
|
||||
}
|
||||
|
||||
float get_Temp4(float *meas) { // meas[0..4]
|
||||
// NTC-Thermistor EPCOS B57540G0502
|
||||
// [ T/C , R/R25 , alpha ] :
|
||||
// [ -55.0 , 51.991 , 6.4 ]
|
||||
// [ -50.0 , 37.989 , 6.2 ]
|
||||
// [ -45.0 , 28.07 , 5.9 ]
|
||||
// [ -40.0 , 20.96 , 5.7 ]
|
||||
// [ -35.0 , 15.809 , 5.5 ]
|
||||
// [ -30.0 , 12.037 , 5.4 ]
|
||||
// [ -25.0 , 9.2484 , 5.2 ]
|
||||
// [ -20.0 , 7.1668 , 5.0 ]
|
||||
// [ -15.0 , 5.5993 , 4.9 ]
|
||||
// [ -10.0 , 4.4087 , 4.7 ]
|
||||
// [ -5.0 , 3.4971 , 4.6 ]
|
||||
// [ 0.0 , 2.7936 , 4.4 ]
|
||||
// [ 5.0 , 2.2468 , 4.3 ]
|
||||
// [ 10.0 , 1.8187 , 4.2 ]
|
||||
// [ 15.0 , 1.4813 , 4.0 ]
|
||||
// [ 20.0 , 1.2136 , 3.9 ]
|
||||
// [ 25.0 , 1.0000 , 3.8 ]
|
||||
// [ 30.0 , 0.82845 , 3.7 ]
|
||||
// [ 35.0 , 0.68991 , 3.6 ]
|
||||
// [ 40.0 , 0.57742 , 3.5 ]
|
||||
// -> Steinhart–Hart coefficients (polyfit):
|
||||
float p0 = 1.09698417e-03,
|
||||
p1 = 2.39564629e-04,
|
||||
p2 = 2.48821437e-06,
|
||||
p3 = 5.84354921e-08;
|
||||
// T/K = 1/( p0 + p1*ln(R) + p2*ln(R)^2 + p3*ln(R)^3 )
|
||||
float Rf = 220e3; // Rf = 220k
|
||||
float g = meas[4]/Rf;
|
||||
float R = (meas[0]-meas[3]) / g; // meas[0,3,4] > 0 ?
|
||||
float T = 0; // T/Kelvin
|
||||
if (R > 0) T = 1/( p0 + p1*log(R) + p2*log(R)*log(R) + p3*log(R)*log(R)*log(R) );
|
||||
return T - 273.15; // Celsius
|
||||
// DFM-06: meas20 * 16 = meas24
|
||||
// -> (meas24[0]-meas24[3])/meas24[4]=(meas20[0]-meas20[3])/meas20[4]
|
||||
}
|
||||
|
||||
|
||||
#define RSNbit 0x0100 // radiosonde DFM-06,DFM-09
|
||||
#define PSNbit 0x0200 // pilotsonde PS-15
|
||||
|
||||
#define SNbit 0x0100
|
||||
int conf_out(uint8_t *conf_bits,uint32_t m) {
|
||||
int conf_id;
|
||||
int ret = 0;
|
||||
int val, hl;
|
||||
static int chAbit, chA[2];
|
||||
uint32_t SN6, SN9;
|
||||
uint32_t SN6, SN9, SN15;
|
||||
static int ch7bit, ch7[2];
|
||||
|
||||
conf_id = bits2val(conf_bits, 4);
|
||||
|
||||
//if (conf_id > 6) chan[m].dfm6.SN6 = 0; //// gpx.sonde_typ & 0xF = 9; // SNbit?
|
||||
|
||||
if ((chan[m].dfm6.sonde_typ & 0xFF) < 9 && conf_id == 6) {
|
||||
SN6 = bits2val(conf_bits+4, 4*6); // DFM-06: Kanal 6
|
||||
if ( SN6 == chan[m].dfm6.SN6 ) { // nur Nibble-Werte 0..9
|
||||
chan[m].dfm6.sonde_typ = SNbit | 6;
|
||||
if ( SN6 == chan[m].dfm6.SN6 && SN6 != 0) { // nur Nibble-Werte 0..9
|
||||
chan[m].dfm6.sonde_typ = RSNbit | 6;
|
||||
ret = 6;
|
||||
printf("DFM6\n");
|
||||
}
|
||||
else {
|
||||
chan[m].dfm6.sonde_typ = 0;
|
||||
|
@ -3346,8 +3547,9 @@ int conf_out(uint8_t *conf_bits,uint32_t m) {
|
|||
if (chAbit == 3) { // DFM-09: Kanal A
|
||||
SN9 = (chA[1] << 16) | chA[0];
|
||||
if ( SN9 == chan[m].dfm6.SN9 ) {
|
||||
chan[m].dfm6.sonde_typ = SNbit | 9;
|
||||
chan[m].dfm6.sonde_typ = RSNbit | 9;
|
||||
ret = 9;
|
||||
printf("DFM9\n");
|
||||
}
|
||||
else {
|
||||
chan[m].dfm6.sonde_typ = 0;
|
||||
|
@ -3357,6 +3559,24 @@ int conf_out(uint8_t *conf_bits,uint32_t m) {
|
|||
}
|
||||
}
|
||||
|
||||
if (conf_id == 0x7) { // 0x70xxxxy
|
||||
val = bits2val(conf_bits+8, 4*5);
|
||||
hl = (val & 1) == 0;
|
||||
ch7[hl] = (val >> 4) & 0xFFFF;
|
||||
ch7bit |= 1 << hl;
|
||||
if (ch7bit == 3) { // PS-15: Kanal 7
|
||||
SN15 = (ch7[1] << 16) | ch7[0];
|
||||
if ( SN15 == chan[m].dfm6.SN15 ) {
|
||||
chan[m].dfm6.sonde_typ = PSNbit | 15;
|
||||
ret = 15;
|
||||
}
|
||||
else {
|
||||
chan[m].dfm6.sonde_typ = 0;
|
||||
}
|
||||
chan[m].dfm6.SN15 = SN15;
|
||||
ch7bit = 0;
|
||||
}
|
||||
}
|
||||
if (conf_id >= 0 && conf_id <= 4) {
|
||||
val = bits2val(conf_bits+4, 4*6);
|
||||
chan[m].dfm6.meas24[conf_id] = fl24(val);
|
||||
|
@ -3387,7 +3607,7 @@ void print_gpx(uint32_t m) {
|
|||
int i, j;
|
||||
char typp;
|
||||
|
||||
if (chan[m].dfm6.sonde_typ & SNbit)
|
||||
if (chan[m].dfm6.sonde_typ & RSNbit)
|
||||
{
|
||||
if ((chan[m].dfm6.sonde_typ & 0xFF) == 6) {
|
||||
sprintf(chan[m].dfm6.id,"D6%06X", chan[m].dfm6.SN6);
|
||||
|
@ -3397,13 +3617,20 @@ void print_gpx(uint32_t m) {
|
|||
sprintf(chan[m].dfm6.id,"D9%06u", chan[m].dfm6.SN9);
|
||||
typp='9';
|
||||
}
|
||||
chan[m].dfm6.sonde_typ ^= SNbit;
|
||||
chan[m].dfm6.sonde_typ ^= RSNbit;
|
||||
}
|
||||
|
||||
if((chan[m].dfm6.id[0]!='D')||(chan[m].dfm6.id[1]!='6')&&(chan[m].dfm6.id[1]!='9'))
|
||||
if (chan[m].dfm6.sonde_typ & PSNbit) {
|
||||
if ((chan[m].dfm6.sonde_typ & 0xFF) == 15) {
|
||||
sprintf(chan[m].dfm6.id,"DF%06u", chan[m].dfm6.SN15);
|
||||
typp='F';
|
||||
}
|
||||
chan[m].dfm6.sonde_typ ^= PSNbit;
|
||||
}
|
||||
|
||||
if((chan[m].dfm6.id[0]!='D')||(chan[m].dfm6.id[1]!='6')&&(chan[m].dfm6.id[1]!='9')&&(chan[m].dfm6.id[1]!='F'))
|
||||
chan[m].dfm6.id[0]=0;
|
||||
|
||||
printf("%d:DFM %s ",m+1,chan[m].dfm6.id+2);
|
||||
printf("%d:DFM %s ",m+1,chan[m].dfm6.id+2);
|
||||
printf("[%3d] ", chan[m].dfm6.frnr);
|
||||
printf("lat: %.6f ", chan[m].dfm6.lat);
|
||||
printf("lon: %.6f ", chan[m].dfm6.lon);
|
||||
|
@ -3412,7 +3639,9 @@ void print_gpx(uint32_t m) {
|
|||
printf("D: %5.1f ", chan[m].dfm6.dir);
|
||||
printf("vV: %5.2f ", chan[m].dfm6.vertV);
|
||||
float t = get_Temp(chan[m].dfm6.meas24);
|
||||
float t4 = get_Temp4(chan[m].dfm6.meas24);
|
||||
if (t > -270.0) printf("T=%.1fC ", t);
|
||||
if (t4 > -270.0) printf("T4=%.1fC ", t4);
|
||||
if ((chan[m].dfm6.sonde_typ & 0xFF) == 9) {
|
||||
printf("U: %.2fV ", chan[m].dfm6.status[0]);
|
||||
printf("Ti: %.2fC ", chan[m].dfm6.status[1]-270.0);
|
||||
|
@ -3495,7 +3724,6 @@ static char sendDFM(uint32_t m){
|
|||
|
||||
tmp[16]=0;
|
||||
strcat(s,tmp);
|
||||
//dopisanie znaku TODO
|
||||
|
||||
tmp[0] = (char)(chan[m].mycallc/16777216UL);
|
||||
tmp[1] = (char)(chan[m].mycallc/65536UL&255UL);
|
||||
|
|
Ładowanie…
Reference in New Issue