/* decode ephemeris ----------------------------------------------------------*/ static int decode_gpsephem(int sat, raw_t *raw) { eph_t eph={0}; unsigned char *puiTmp = (raw->buff)+2; unsigned short week; double toc; trace(4,"decode_ephem: sat=%2d\n",sat); eph.crs = R4(&puiTmp[ 2]); eph.deln = R4(&puiTmp[ 6]) * 1e+3; eph.M0 = R8(&puiTmp[ 10]); eph.cuc = R4(&puiTmp[ 18]); eph.e = R8(&puiTmp[ 22]); eph.cus = R4(&puiTmp[ 30]); eph.A = pow(R8(&puiTmp[ 34]), 2); eph.toes = R8(&puiTmp[ 42]) * 1e-3; eph.cic = R4(&puiTmp[ 50]); eph.OMG0 = R8(&puiTmp[ 54]); eph.cis = R4(&puiTmp[ 62]); eph.i0 = R8(&puiTmp[ 66]); eph.crc = R4(&puiTmp[ 74]); eph.omg = R8(&puiTmp[ 78]); eph.OMGd = R8(&puiTmp[ 86]) * 1e+3; eph.idot = R8(&puiTmp[ 94]) * 1e+3; eph.tgd[0] = R4(&puiTmp[102]) * 1e-3; toc = R8(&puiTmp[106]) * 1e-3; eph.f2 = R4(&puiTmp[114]) * 1e+3; eph.f1 = R4(&puiTmp[118]); eph.f0 = R4(&puiTmp[122]) * 1e-3; eph.sva = uraindex(I2(&puiTmp[126])); eph.iode = I2(&puiTmp[128]); eph.iodc = I2(&puiTmp[130]); eph.code = I2(&puiTmp[132]); eph.flag = I2(&puiTmp[134]); week = I2(&puiTmp[136]); eph.fit = 0; if (week>=4096) { trace(2,"nvs gps ephemeris week error: sat=%2d week=%d\n",sat,week); return -1; } eph.week=adjgpsweek(week); eph.toe=gpst2time(eph.week,eph.toes); eph.toc=gpst2time(eph.week,toc); eph.ttr=raw->time; if (!strstr(raw->opt,"-EPHALL")) { if (eph.iode==raw->nav.eph[sat-1].iode) return 0; /* unchanged */ } eph.sat=sat; raw->nav.eph[sat-1]=eph; raw->ephsat=sat; return 2; }
/* decode binex mesaage 0x01-06: decoded qzss ephmemeris ---------------------*/ static int decode_bnx_01_06(raw_t *raw, unsigned char *buff, int len) { eph_t eph={0}; unsigned char *p=buff; double tow,ura,sqrtA; int prn,flag; trace(4,"binex 0x01-06: len=%d\n",len); if (len>=127) { prn =U1(p); p+=1; eph.week =U2(p); p+=2; tow =I4(p); p+=4; eph.toes =I4(p); p+=4; eph.tgd[0]=R4(p); p+=4; eph.iodc =I4(p); p+=4; eph.f2 =R4(p); p+=4; eph.f1 =R4(p); p+=4; eph.f0 =R4(p); p+=4; eph.iode =I4(p); p+=4; eph.deln =R4(p)*SC2RAD; p+=4; eph.M0 =R8(p); p+=8; eph.e =R8(p); p+=8; sqrtA =R8(p); p+=8; eph.cic =R4(p); p+=4; eph.crc =R4(p); p+=4; eph.cis =R4(p); p+=4; eph.crs =R4(p); p+=4; eph.cuc =R4(p); p+=4; eph.cus =R4(p); p+=4; eph.OMG0 =R8(p); p+=8; eph.omg =R8(p); p+=8; eph.i0 =R8(p); p+=8; eph.OMGd =R4(p)*SC2RAD; p+=4; eph.idot =R4(p)*SC2RAD; p+=4; ura =R4(p)*0.1; p+=4; eph.svh =U2(p); p+=2; flag =U2(p); } else { trace(2,"binex 0x01-06: length error len=%d\n",len); return -1; } if (!(eph.sat=satno(SYS_QZS,prn))) { trace(2,"binex 0x01-06: satellite error prn=%d\n",prn); return 0; } eph.A=sqrtA*sqrtA; eph.toe=gpst2time(eph.week,eph.toes); eph.toc=gpst2time(eph.week,eph.toes); eph.ttr=adjweek(eph.toe,tow); eph.fit=(flag&0x01)?0.0:2.0; /* 0:2hr,1:>2hr */ eph.sva=uraindex(ura); eph.code=2; /* codes on L2 channel */ if (!strstr(raw->opt,"-EPHALL")) { if (raw->nav.eph[eph.sat-1].iode==eph.iode&& raw->nav.eph[eph.sat-1].iodc==eph.iodc) return 0; /* unchanged */ } raw->nav.eph[eph.sat-1]=eph; raw->ephsat=eph.sat; return 2; }
/* decode binex mesaage 0x01-04: decoded galileo ephmemeris ------------------*/ static int decode_bnx_01_04(raw_t *raw, unsigned char *buff, int len) { eph_t eph={0}; unsigned char *p=buff; double tow,ura,sqrtA; int prn; trace(4,"binex 0x01-04: len=%d\n",len); if (len>=127) { prn =U1(p)+1; p+=1; eph.week =U2(p); p+=2; tow =I4(p); p+=4; eph.toes =I4(p); p+=4; eph.tgd[0]=R4(p); p+=4; /* BGD E5a/E1 */ eph.tgd[1]=R4(p); p+=4; /* BGD E5b/E1 */ eph.iode =I4(p); p+=4; /* IODnav */ eph.f2 =R4(p); p+=4; eph.f1 =R4(p); p+=4; eph.f0 =R4(p); p+=4; eph.deln =R4(p)*SC2RAD; p+=4; eph.M0 =R8(p); p+=8; eph.e =R8(p); p+=8; sqrtA =R8(p); p+=8; eph.cic =R4(p); p+=4; eph.crc =R4(p); p+=4; eph.cis =R4(p); p+=4; eph.crs =R4(p); p+=4; eph.cuc =R4(p); p+=4; eph.cus =R4(p); p+=4; eph.OMG0 =R8(p); p+=8; eph.omg =R8(p); p+=8; eph.i0 =R8(p); p+=8; eph.OMGd =R4(p)*SC2RAD; p+=4; eph.idot =R4(p)*SC2RAD; p+=4; ura =R4(p)*0.1; p+=4; eph.svh =U2(p); p+=2; eph.code =U2(p); /* data source */ } else { trace(2,"binex 0x01-04: length error len=%d\n",len); return -1; } if (!(eph.sat=satno(SYS_GAL,prn))) { trace(2,"binex 0x01-04: satellite error prn=%d\n",prn); return -1; } eph.A=sqrtA*sqrtA; eph.iode=eph.iodc; eph.toe=gpst2time(eph.week,eph.toes); eph.toc=gpst2time(eph.week,eph.toes); eph.ttr=adjweek(eph.toe,tow); eph.sva=uraindex(ura); if (!strstr(raw->opt,"-EPHALL")) { if (raw->nav.eph[eph.sat-1].iode==eph.iode&& raw->nav.eph[eph.sat-1].iodc==eph.iodc) return 0; /* unchanged */ } raw->nav.eph[eph.sat-1]=eph; raw->ephsat=eph.sat; return 2; }