コード例 #1
0
ファイル: sdrnav_gal.cpp プロジェクト: jks-prv/Beagle_SDR_GPS
/* decode Galileo navigation data (I/NAV word 10) -------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_word10(const uint8_t *buff, sdrnav_t *nav)
{
    //   0    | 6
    //   6    | 4
    //  10    | 16
    //  26    | 11
    //  37    | 16
    //  53    | 16
    //  69    | 13
    //  82    |  2
    //  84    |  2
    //  86    | 16 A_0G
    // 102    | 12 A_1G
    // 112 - ---
    // 114, 2 |  8 t_0G
    // 122,10 |  6 WN_0G
    // 128,16
    sdreph_t *eph = &nav->sdreph;
    Ephemeris[nav->sat].A_0G  = getbits (buff, OFFSET1+ 86, 16)*P2_35;
    Ephemeris[nav->sat].A_1G  = getbits2(buff, OFFSET1+102, 10, OFFSET2+0, 2)*P2_30*P2_21;
    Ephemeris[nav->sat].t_0G  = getbitu (buff, OFFSET2+  2, 8)*3600;
    Ephemeris[nav->sat].WN_0G = getbitu (buff, OFFSET2+ 10, 6);    
    //printf("word10 GST-GPS %s: %e %e %d %d\n", PRN(nav->sat),
    //       Ephemeris[nav->sat].A_0G, Ephemeris[nav->sat].A_1G,
    //       Ephemeris[nav->sat].t_0G, Ephemeris[nav->sat].WN_0G);
}
コード例 #2
0
ファイル: sdrnav_gal.cpp プロジェクト: jks-prv/Beagle_SDR_GPS
/* decode Galileo navigation data (I/NAV word 4) -------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_word4(const uint8_t *buff, sdrnav_t *nav)
{
    sdreph_t *eph = &nav->sdreph;
    int oldiodc=eph->eph.iodc;

    eph->eph.iodc  =getbitu( buff,OFFSET1+ 6,10);
    eph->eph.cic   =getbits( buff,OFFSET1+22,16)*P2_29;
    eph->eph.cis   =getbits( buff,OFFSET1+38,16)*P2_29;
    eph->toc_gst   =getbitu( buff,OFFSET1+54,14)*60;
    eph->eph.f0    =getbits( buff,OFFSET1+68,31)*P2_34;
    eph->eph.f1    =getbits2(buff,OFFSET1+99,13,OFFSET2+ 0, 8)*P2_46;
    eph->eph.f2    =getbits( buff,OFFSET2+ 8, 6)*P2_59;
    eph->eph.iode  =eph->eph.iodc;

    /* compute time of clock */
    if (eph->week_gst!=0) {
        eph->eph.toc=gst2time(eph->week_gst,eph->toc_gst);
        Ephemeris[nav->sat].Page4(eph->eph.iodc, eph->eph.cic, eph->eph.cis, eph->eph.f0, eph->eph.f1, eph->eph.f2, time2gpst(eph->eph.toc, NULL));
    } else {
        Ephemeris[nav->sat].Page4(eph->eph.iodc, eph->eph.cic, eph->eph.cis, eph->eph.f0, eph->eph.f1, eph->eph.f2);
    }

    /* ephemeris update flag */
    if (oldiodc-eph->eph.iodc!=0) eph->update=ON;

    /* subframe counter */
    eph->cnt++;
}
コード例 #3
0
/* decode GPS/QZS navigation data (subframe 3) ---------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_subfrm3(const uint8_t *buff, sdreph_t *eph)
{
    int oldiode=eph->eph.iode;

    eph->tow_gpst=getbitu( buff, 30,17)*6.0;
    eph->eph.cic =getbits( buff, 60,16)*P2_29;
    eph->eph.OMG0=getbits2(buff, 76, 8, 90,24)*P2_31*SC2RAD;
    eph->eph.cis =getbits( buff,120,16)*P2_29;
    eph->eph.i0  =getbits2(buff,136, 8,150,24)*P2_31*SC2RAD;
    eph->eph.crc =getbits( buff,180,16)*P2_5;
    eph->eph.omg =getbits2(buff,196, 8,210,24)*P2_31*SC2RAD;
    eph->eph.OMGd=getbits( buff,240,24)*P2_43*SC2RAD;
    eph->eph.iode=getbitu( buff,270, 8);
    eph->eph.idot=getbits( buff,278,14)*P2_43*SC2RAD;

    /* ephemeris update flag */
    if (oldiode-eph->eph.iode!=0) eph->update=ON; 

    /* subframe counter */
    eph->cnt++;
}
コード例 #4
0
ファイル: sdrnav_gal.cpp プロジェクト: jks-prv/Beagle_SDR_GPS
/* decode Galileo navigation data (I/NAV word 3) -------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_word3(const uint8_t *buff, sdrnav_t *nav)
{
    sdreph_t *eph = &nav->sdreph;
    int oldiodc=eph->eph.iodc;

    eph->eph.iodc  =getbitu( buff,OFFSET1+  6,10);
    eph->eph.OMGd  =getbits( buff,OFFSET1+ 16,24)*P2_43*SC2RAD;
    eph->eph.deln  =getbits( buff,OFFSET1+ 40,16)*P2_43*SC2RAD;
    eph->eph.cuc   =getbits( buff,OFFSET1+ 56,16)*P2_29;
    eph->eph.cus   =getbits( buff,OFFSET1+ 72,16)*P2_29;
    eph->eph.crc   =getbits( buff,OFFSET1+ 88,16)*P2_5;
    eph->eph.crs   =getbits2(buff,OFFSET1+104, 8,OFFSET2+ 0, 8)*P2_5;
    eph->eph.sva   =0; /*getbitu( buff,OFFSET2+  8,8); (undefined) */
    eph->eph.iode  =eph->eph.iodc;

    Ephemeris[nav->sat].Page3(eph->eph.iodc, eph->eph.OMGd, eph->eph.deln, eph->eph.cuc, eph->eph.cus, eph->eph.crc, eph->eph.crs);

    /* ephemeris update flag */
    if (oldiodc-eph->eph.iodc!=0) eph->update=ON;

    /* ephemeris counter */
    eph->cnt++;
}
コード例 #5
0
/* decode GPS/QZS navigation data (subframe 2) ---------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_subfrm2(const uint8_t *buff, sdreph_t *eph)
{
    double sqrtA;
    int oldiode=eph->eph.iode;

    eph->tow_gpst=getbitu( buff, 30,17)*6.0;
    eph->eph.iode=getbitu( buff, 60, 8);
    eph->eph.crs =getbits( buff, 68,16)*P2_5;
    eph->eph.deln=getbits( buff, 90,16)*P2_43*SC2RAD;
    eph->eph.M0  =getbits2(buff,106, 8,120,24)*P2_31*SC2RAD;
    eph->eph.cuc =getbits( buff,150,16)*P2_29;
    eph->eph.e   =getbitu2(buff,166, 8,180,24)*P2_33;
    eph->eph.cus =getbits( buff,210,16)*P2_29;
    sqrtA        =getbitu2(buff,226, 8,240,24)*P2_19;
    eph->eph.toes=getbitu( buff,270,16)*16.0;
    eph->eph.fit =getbitu( buff,286, 1);
    eph->eph.A   =sqrtA*sqrtA;

    /* ephemeris update flag */
    if (oldiode-eph->eph.iode!=0) eph->update=ON; 
    
    /* subframe counter */
    eph->cnt++;
}
コード例 #6
0
ファイル: rcvraw.c プロジェクト: Allidylls/RTKLIB
/* decode BeiDou D1 ephemeris --------------------------------------------------
* decode BeiDou D1 ephemeris (IGSO/MEO satellites) (ref [3] 5.2)
* args   : unsigned char *buff I beidou D1 subframe bits
*                                  buff[ 0- 37]: subframe 1 (300 bits)
*                                  buff[38- 75]: subframe 2
*                                  buff[76-113]: subframe 3
*          eph_t    *eph    IO  ephemeris structure
* return : status (1:ok,0:error)
*-----------------------------------------------------------------------------*/
extern int decode_bds_d1(const unsigned char *buff, eph_t *eph)
{
    double toc_bds,sqrtA;
    unsigned int toe1,toe2,sow1,sow2,sow3;
    int i,frn1,frn2,frn3;
    
    trace(3,"decode_bds_d1:\n");
    
    i=8*38*0; /* subframe 1 */
    frn1       =getbitu (buff,i+ 15, 3);
    sow1       =getbitu2(buff,i+ 18, 8,i+30,12);
    eph->svh   =getbitu (buff,i+ 42, 1); /* SatH1 */
    eph->iodc  =getbitu (buff,i+ 43, 5); /* AODC */
    eph->sva   =getbitu (buff,i+ 48, 4);
    eph->week  =getbitu (buff,i+ 60,13); /* week in BDT */
    toc_bds    =getbitu2(buff,i+ 73, 9,i+ 90, 8)*8.0;
    eph->tgd[0]=getbits (buff,i+ 98,10)*0.1*1E-9;
    eph->tgd[1]=getbits2(buff,i+108, 4,i+120, 6)*0.1*1E-9;
    eph->f2    =getbits (buff,i+214,11)*P2_66;
    eph->f0    =getbits2(buff,i+225, 7,i+240,17)*P2_33;
    eph->f1    =getbits2(buff,i+257, 5,i+270,17)*P2_50;
    eph->iode  =getbitu (buff,i+287, 5); /* AODE */
    
    i=8*38*1; /* subframe 2 */
    frn2       =getbitu (buff,i+ 15, 3);
    sow2       =getbitu2(buff,i+ 18, 8,i+30,12);
    eph->deln  =getbits2(buff,i+ 42,10,i+ 60, 6)*P2_43*SC2RAD;
    eph->cuc   =getbits2(buff,i+ 66,16,i+ 90, 2)*P2_31;
    eph->M0    =getbits2(buff,i+ 92,20,i+120,12)*P2_31*SC2RAD;
    eph->e     =getbitu2(buff,i+132,10,i+150,22)*P2_33;
    eph->cus   =getbits (buff,i+180,18)*P2_31;
    eph->crc   =getbits2(buff,i+198, 4,i+210,14)*P2_6;
    eph->crs   =getbits2(buff,i+224, 8,i+240,10)*P2_6;
    sqrtA      =getbitu2(buff,i+250,12,i+270,20)*P2_19;
    toe1       =getbitu (buff,i+290, 2); /* TOE 2-MSB */
    eph->A     =sqrtA*sqrtA;
    
    i=8*38*2; /* subframe 3 */
    frn3       =getbitu (buff,i+ 15, 3);
    sow3       =getbitu2(buff,i+ 18, 8,i+30,12);
    toe2       =getbitu2(buff,i+ 42,10,i+ 60, 5); /* TOE 5-LSB */
    eph->i0    =getbits2(buff,i+ 65,17,i+ 90,15)*P2_31*SC2RAD;
    eph->cic   =getbits2(buff,i+105, 7,i+120,11)*P2_31;
    eph->OMGd  =getbits2(buff,i+131,11,i+150,13)*P2_43*SC2RAD;
    eph->cis   =getbits2(buff,i+163, 9,i+180, 9)*P2_31;
    eph->idot  =getbits2(buff,i+189,13,i+210, 1)*P2_43*SC2RAD;
    eph->OMG0  =getbits2(buff,i+211,21,i+240,11)*P2_31*SC2RAD;
    eph->omg   =getbits2(buff,i+251,11,i+270,21)*P2_31*SC2RAD;
    eph->toes  =merge_two_u(toe1,toe2,15)*8.0;
    
    /* check consistency of subframe numbers, sows and toe/toc */
    if (frn1!=1||frn2!=2||frn3!=3) {
        trace(3,"decode_bds_d1 error: frn=%d %d %d\n",frn1,frn2,frn3);
        return 0;
    }
    if (sow2!=sow1+6||sow3!=sow2+6) {
        trace(3,"decode_bds_d1 error: sow=%d %d %d\n",sow1,sow2,sow3);
        return 0;
    }
    if (toc_bds!=eph->toes) {
        trace(3,"decode_bds_d1 error: toe=%.0f toc=%.0f\n",eph->toes,toc_bds);
        return 0;
    }
    eph->ttr=bdt2gpst(bdt2time(eph->week,sow1));      /* bdt -> gpst */
    if      (eph->toes>sow1+302400.0) eph->week++;
    else if (eph->toes<sow1-302400.0) eph->week--;
    eph->toe=bdt2gpst(bdt2time(eph->week,eph->toes)); /* bdt -> gpst */
    eph->toc=bdt2gpst(bdt2time(eph->week,toc_bds));   /* bdt -> gpst */
    return 1;
}
コード例 #7
0
ファイル: rcvraw.c プロジェクト: Allidylls/RTKLIB
/* decode BeiDou D2 ephemeris --------------------------------------------------
* decode BeiDou D2 ephemeris (GEO satellites) (ref [3] 5.3)
* args   : unsigned char *buff I beidou D2 subframe 1 page bits
*                                  buff[  0- 37]: page 1 (300 bits)
*                                  buff[ 38- 75]: page 2
*                                  ...
*                                  buff[342-379]: page 10
*          eph_t    *eph    IO  ephemeris structure
* return : status (1:ok,0:error)
*-----------------------------------------------------------------------------*/
extern int decode_bds_d2(const unsigned char *buff, eph_t *eph)
{
    double toc_bds,sqrtA;
    unsigned int f1p4,cucp5,ep6,cicp7,i0p8,OMGdp9,omgp10;
    unsigned int sow1,sow3,sow4,sow5,sow6,sow7,sow8,sow9,sow10;
    int i,f1p3,cucp4,ep5,cicp6,i0p7,OMGdp8,omgp9;
    int pgn1,pgn3,pgn4,pgn5,pgn6,pgn7,pgn8,pgn9,pgn10;
    
    trace(3,"decode_bds_d2:\n");
    
    i=8*38*0; /* page 1 */
    pgn1       =getbitu (buff,i+ 42, 4);
    sow1       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    eph->svh   =getbitu (buff,i+ 46, 1); /* SatH1 */
    eph->iodc  =getbitu (buff,i+ 47, 5); /* AODC */
    eph->sva   =getbitu (buff,i+ 60, 4);
    eph->week  =getbitu (buff,i+ 64,13); /* week in BDT */
    toc_bds    =getbitu2(buff,i+ 77, 5,i+ 90,12)*8.0;
    eph->tgd[0]=getbits (buff,i+102,10)*0.1*1E-9;
    eph->tgd[1]=getbits (buff,i+120,10)*0.1*1E-9;
    
    i=8*38*2; /* page 3 */
    pgn3       =getbitu (buff,i+ 42, 4);
    sow3       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    eph->f0    =getbits2(buff,i+100,12,i+120,12)*P2_33;
    f1p3       =getbits (buff,i+132,4);
    
    i=8*38*3; /* page 4 */
    pgn4       =getbitu (buff,i+ 42, 4);
    sow4       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    f1p4       =getbitu2(buff,i+ 46, 6,i+ 60,12);
    eph->f2    =getbits2(buff,i+ 72,10,i+ 90, 1)*P2_66;
    eph->iode  =getbitu (buff,i+ 91, 5); /* AODE */
    eph->deln  =getbits (buff,i+ 96,16)*P2_43*SC2RAD;
    cucp4      =getbits (buff,i+120,14);
    
    i=8*38*4; /* page 5 */
    pgn5       =getbitu (buff,i+ 42, 4);
    sow5       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    cucp5      =getbitu (buff,i+ 46, 4);
    eph->M0    =getbits3(buff,i+ 50, 2,i+ 60,22,i+ 90, 8)*P2_31*SC2RAD;
    eph->cus   =getbits2(buff,i+ 98,14,i+120, 4)*P2_31;
    ep5        =getbits (buff,i+124,10);
    
    i=8*38*5; /* page 6 */
    pgn6       =getbitu (buff,i+ 42, 4);
    sow6       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    ep6        =getbitu2(buff,i+ 46, 6,i+ 60,16);
    sqrtA      =getbitu3(buff,i+ 76, 6,i+ 90,22,i+120,4)*P2_19;
    cicp6      =getbits (buff,i+124,10);
    eph->A     =sqrtA*sqrtA;
    
    i=8*38*6; /* page 7 */
    pgn7       =getbitu (buff,i+ 42, 4);
    sow7       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    cicp7      =getbitu2(buff,i+ 46, 6,i+ 60, 2);
    eph->cis   =getbits (buff,i+ 62,18)*P2_31;
    eph->toes  =getbitu2(buff,i+ 80, 2,i+ 90,15)*8.0;
    i0p7       =getbits2(buff,i+105, 7,i+120,14);
    
    i=8*38*7; /* page 8 */
    pgn8       =getbitu (buff,i+ 42, 4);
    sow8       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    i0p8       =getbitu2(buff,i+ 46, 6,i+ 60, 5);
    eph->crc   =getbits2(buff,i+ 65,17,i+ 90, 1)*P2_6;
    eph->crs   =getbits (buff,i+ 91,18)*P2_6;
    OMGdp8     =getbits2(buff,i+109, 3,i+120,16);
    
    i=8*38*8; /* page 9 */
    pgn9       =getbitu (buff,i+ 42, 4);
    sow9       =getbitu2(buff,i+ 18, 8,i+ 30,12);
    OMGdp9     =getbitu (buff,i+ 46, 5);
    eph->OMG0  =getbits3(buff,i+ 51, 1,i+ 60,22,i+ 90, 9)*P2_31*SC2RAD;
    omgp9      =getbits2(buff,i+ 99,13,i+120,14);
    
    i=8*38*9; /* page 10 */
    pgn10      =getbitu (buff,i+ 42, 4);
    sow10      =getbitu2(buff,i+ 18, 8,i+ 30,12);
    omgp10     =getbitu (buff,i+ 46, 5);
    eph->idot  =getbits2(buff,i+ 51, 1,i+ 60,13)*P2_43*SC2RAD;
    
    /* check consistency of page numbers, sows and toe/toc */
    if (pgn1!=1||pgn3!=3||pgn4!=4||pgn5!=5||pgn6!=6||pgn7!=7||pgn8!=8||pgn9!=9||
        pgn10!=10) {
        trace(3,"decode_bds_d2 error: pgn=%d %d %d %d %d %d %d %d %d\n",
              pgn1,pgn3,pgn4,pgn5,pgn6,pgn7,pgn8,pgn9,pgn10);
        return 0;
    }
    if (sow3!=sow1+6||sow4!=sow3+3||sow5!=sow4+3||sow6!=sow5+3||
        sow7!=sow6+3||sow8!=sow7+3||sow9!=sow8+3||sow10!=sow9+3) {
        trace(3,"decode_bds_d2 error: sow=%d %d %d %d %d %d %d %d %d\n",
              sow1,sow3,sow4,sow5,sow6,sow7,sow8,sow9,sow10);
        return 0;
    }
    if (toc_bds!=eph->toes) {
        trace(3,"decode_bds_d2 error: toe=%.0f toc=%.0f\n",eph->toes,toc_bds);
        return 0;
    }
    eph->f1  =merge_two_s(f1p3  ,f1p4  ,18)*P2_50;
    eph->cuc =merge_two_s(cucp4 ,cucp5 , 4)*P2_31;
    eph->e   =merge_two_s(ep5   ,ep6   ,22)*P2_33;
    eph->cic =merge_two_s(cicp6 ,cicp7 , 8)*P2_31;
    eph->i0  =merge_two_s(i0p7  ,i0p8  ,11)*P2_31*SC2RAD;
    eph->OMGd=merge_two_s(OMGdp8,OMGdp9, 5)*P2_43*SC2RAD;
    eph->omg =merge_two_s(omgp9 ,omgp10, 5)*P2_31*SC2RAD;
    
    eph->ttr=bdt2gpst(bdt2time(eph->week,sow1));      /* bdt -> gpst */
    if      (eph->toes>sow1+302400.0) eph->week++;
    else if (eph->toes<sow1-302400.0) eph->week--;
    eph->toe=bdt2gpst(bdt2time(eph->week,eph->toes)); /* bdt -> gpst */
    eph->toc=bdt2gpst(bdt2time(eph->week,toc_bds));   /* bdt -> gpst */
    return 1;
}