/* decode binex mesaage 0x01-02: decoded glonass ephmemeris ------------------*/ static int decode_bnx_01_02(raw_t *raw, unsigned char *buff, int len) { geph_t geph={0}; unsigned char *p=buff; double tod,tof,tau_gps; int prn,day,leap; trace(4,"binex 0x01-02: len=%d\n",len); if (len>=119) { prn =U1(p)+1; p+=1; day =U2(p); p+=2; tod =U4(p); p+=4; geph.taun =-R8(p); p+=8; geph.gamn =R8(p); p+=8; tof =U4(p); p+=4; geph.pos[0]=R8(p)*1E3; p+=8; geph.vel[0]=R8(p)*1E3; p+=8; geph.acc[0]=R8(p)*1E3; p+=8; geph.pos[1]=R8(p)*1E3; p+=8; geph.vel[1]=R8(p)*1E3; p+=8; geph.acc[1]=R8(p)*1E3; p+=8; geph.pos[2]=R8(p)*1E3; p+=8; geph.vel[2]=R8(p)*1E3; p+=8; geph.acc[2]=R8(p)*1E3; p+=8; geph.svh =U1(p)&0x1; p+=1; geph.frq =I1(p); p+=1; geph.age =U1(p); p+=1; leap =U1(p); p+=1; tau_gps =R8(p); p+=8; geph.dtaun =R8(p); } else { trace(2,"binex 0x01-02: length error len=%d\n",len); return -1; } if (!(geph.sat=satno(SYS_GLO,prn))) { trace(2,"binex 0x01-02: satellite error prn=%d\n",prn); return -1; } if (raw->time.time==0) return 0; geph.toe=utc2gpst(adjday(raw->time,tod-10800.0)); geph.tof=utc2gpst(adjday(raw->time,tof-10800.0)); geph.iode=(int)(fmod(tod+10800.0,86400.0)/900.0+0.5); if (!strstr(raw->opt,"-EPHALL")) { if (fabs(timediff(geph.toe,raw->nav.geph[prn-MINPRNGLO].toe))<1.0&& geph.svh==raw->nav.geph[prn-MINPRNGLO].svh) return 0; /* unchanged */ } raw->nav.geph[prn-1]=geph; raw->ephsat=geph.sat; return 2; }
/* decode gloephem -----------------------------------------------------------*/ static int decode_gloephem(int sat, raw_t *raw) { geph_t geph={0}; unsigned char *p=(raw->buff)+2; int prn,tk,tb; if (raw->len>=93) { prn =I1(p+ 1); geph.frq =I1(p+ 2); geph.pos[0]=R8(p+ 3); geph.pos[1]=R8(p+11); geph.pos[2]=R8(p+19); geph.vel[0]=R8(p+27) * 1e+3; geph.vel[1]=R8(p+35) * 1e+3; geph.vel[2]=R8(p+43) * 1e+3; geph.acc[0]=R8(p+51) * 1e+6; geph.acc[1]=R8(p+59) * 1e+6; geph.acc[2]=R8(p+67) * 1e+6; tb = R8(p+75) * 1e-3; tk = tb; geph.gamn =R4(p+83); geph.taun =R4(p+87) * 1e-3; geph.age =I2(p+91); } else { trace(2,"nvs NE length error: len=%d\n",raw->len); return -1; } if (!(geph.sat=satno(SYS_GLO,prn))) { trace(2,"nvs NE satellite error: prn=%d\n",prn); return -1; } if (raw->time.time==0) return 0; geph.iode=(tb/900)&0x3F; geph.toe=utc2gpst(adjday(raw->time,tb-10800.0)); geph.tof=utc2gpst(adjday(raw->time,tk-10800.0)); #if 0 /* check illegal ephemeris by toe */ tt=timediff(raw->time,geph.toe); if (fabs(tt)>3600.0) { trace(3,"nvs NE illegal toe: prn=%2d tt=%6.0f\n",prn,tt); return 0; } #endif #if 0 /* check illegal ephemeris by frequency number consistency */ if (raw->nav.geph[prn-MINPRNGLO].toe.time&& geph.frq!=raw->nav.geph[prn-MINPRNGLO].frq) { trace(2,"nvs NE illegal freq change: prn=%2d frq=%2d->%2d\n",prn, raw->nav.geph[prn-MINPRNGLO].frq,geph.frq); return -1; } if (!strstr(raw->opt,"-EPHALL")) { if (fabs(timediff(geph.toe,raw->nav.geph[prn-MINPRNGLO].toe))<1.0&& geph.svh==raw->nav.geph[prn-MINPRNGLO].svh) return 0; } #endif raw->nav.geph[prn-1]=geph; raw->ephsat=geph.sat; return 2; }