Ignore:
Timestamp:
Sep 24, 2024, 12:02:48 PM (4 weeks ago)
Author:
stuerze
Message:

data field range checks added within RTCM3 Ephemeris decoders mainly regarding TOC and TOE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM3/RTCM3Decoder.cpp

    r10539 r10544  
    10421042
    10431043    GETBITS(i, 6)
     1044    if (i < 1 || i > 63 ) {
     1045#ifdef BNC_DEBUG_BCEP
     1046      emit(newMessage(QString("%1: Block %2 (G) PRN# is out of range: %3!")
     1047           .arg(_staID)
     1048           .arg(1019,4)
     1049           .arg(i).toLatin1(), true));
     1050#endif
     1051      return false;
     1052    }
    10441053    eph._prn.set('G', i);
    10451054    GETBITS(week, 10)
     1055    if (week < 0 || week > 1023) {
     1056#ifdef BNC_DEBUG_BCEP
     1057      emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
     1058           .arg(_staID)
     1059           .arg(1019,4)
     1060           .arg(eph._prn.toString().c_str())
     1061           .arg(week).toLatin1(), true));
     1062#endif
     1063      return false;
     1064    }
    10461065    GETBITS(i, 4)
    10471066    eph._ura = accuracyFromIndex(i, eph.type());
     
    10511070    GETBITS(i, 16)
    10521071    i <<= 4;
     1072    if (i < 0 || i > 604784) {
     1073#ifdef BNC_DEBUG_BCEP
     1074      emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
     1075           .arg(_staID)
     1076           .arg(1019,4)
     1077           .arg(eph._prn.toString().c_str())
     1078           .arg(i).toLatin1(), true));
     1079#endif
     1080      return false;
     1081    }
    10531082    eph._TOC.set(i * 1000);
    10541083    GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
     
    10731102    GETBITS(i, 16)
    10741103    i <<= 4;
     1104    if (i < 0 || i > 604784) {
     1105#ifdef BNC_DEBUG_BCEP
     1106      emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
     1107           .arg(_staID)
     1108           .arg(1019,4)
     1109           .arg(eph._prn.toString().c_str())
     1110           .arg(i).toLatin1(), true));
     1111#endif
     1112      return false;
     1113    }
    10751114    eph._TOEsec = i;
    10761115    bncTime t;
     
    11231162
    11241163    GETBITS(sv, 6)
     1164    if (sv < 1 || sv > 63) {
     1165#ifdef BNC_DEBUG_BCEP
     1166      emit(newMessage(QString("%1: Block %2 (R):  SLOT# is unknown (0) or out of range: %3!")
     1167           .arg(_staID)
     1168           .arg(1020,4)
     1169           .arg(sv).toLatin1(), true));
     1170#endif
     1171      return false;
     1172    }
    11251173    eph._prn.set('R', sv);
    11261174
    11271175    GETBITS(i, 5)
     1176    if (i < 0 || i > 20) {
     1177#ifdef BNC_DEBUG_BCEP
     1178      emit(newMessage(QString("%1: Block %2 (%3): FRQ CHN# is out of range: %4")
     1179           .arg(_staID)
     1180           .arg(1020,4)
     1181           .arg(eph._prn.toString().c_str())
     1182           .arg(i).toLatin1(), true));
     1183#endif
     1184      return false;
     1185    }
    11281186    eph._frequency_number = i - 7;
    11291187    GETBITS(eph._almanac_health, 1) /* almanac healthy */
    11301188    GETBITS(eph._almanac_health_availablility_indicator, 1) /* almanac health ok */
    1131 /*
    1132     if (eph._almanac_health_availablility_indicator == 0.0) {
    1133 #ifdef BNC_DEBUG_BCEP
    1134       emit(newMessage(QString("%1: Block %2 (%3): ALM = %4: missing data!")
    1135            .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str())
    1136            .arg(eph._almanac_health_availablility_indicator).toLatin1(), true));
    1137 #endif
    1138       return false;
    1139     }
    1140 */
    11411189    GETBITS(eph._P1, 2) /*  P1 */
    11421190    GETBITS(i, 5)
     1191    if (i < 0 || i > 23) {
     1192#ifdef BNC_DEBUG_BCEP
     1193      emit(newMessage(QString("%1: Block %2 (%3): T_k (bits 11-7) is out of range: %4")
     1194           .arg(_staID)
     1195           .arg(1020,4)
     1196           .arg(eph._prn.toString().c_str())
     1197           .arg(i).toLatin1(), true));
     1198#endif
     1199      return false;
     1200    }
    11431201    tk = i * 60 * 60;
    11441202    GETBITS(i, 6)
     1203    if (i < 0 || i > 59) {
     1204#ifdef BNC_DEBUG_BCEP
     1205      emit(newMessage(QString("%1: Block %2 (%3): T_k (bits 6-1) is out of range: %4")
     1206           .arg(_staID)
     1207           .arg(1020,4)
     1208           .arg(eph._prn.toString().c_str())
     1209           .arg(i).toLatin1(), true));
     1210#endif
     1211      return false;
     1212    }
    11451213    tk += i * 60;
    11461214    GETBITS(i, 1)
     1215    if (i < 0 || i > 1) {
     1216#ifdef BNC_DEBUG_BCEP
     1217      emit(newMessage(QString("%1: Block %2 (%3): T_k (bit 0) is out of range: %4")
     1218           .arg(_staID)
     1219           .arg(1020,4)
     1220           .arg(eph._prn.toString().c_str())
     1221           .arg(i).toLatin1(), true));
     1222#endif
     1223      return false;
     1224    }
    11471225    tk += i * 30;
    11481226    eph._tki = tk - 3*60*60;
     
    11531231    GETBITS(eph._P2, 1)  /* P2 */
    11541232    GETBITS(i, 7)
    1155     eph._TOC.setTk(i * 15 * 60 * 1000); /* tb */
     1233    i *= 15;
     1234    if (i < 15 || i > 1425) {
     1235#ifdef BNC_DEBUG_BCEP
     1236      emit(newMessage(QString("%1: Block %2 (%3): T_b is out of range: %4")
     1237           .arg(_staID)
     1238           .arg(1020,4)
     1239           .arg(eph._prn.toString().c_str())
     1240           .arg(i).toLatin1(), true));
     1241#endif
     1242      return false;
     1243    }
     1244    eph._TOC.setTk(i * 60 * 1000); /* tb */
    11561245
    11571246    GETFLOATSIGNM(eph._x_velocity,    24, 1.0 / (double )(1 << 20))
     
    12521341
    12531342    GETBITS(i, 4)
     1343    if (i < 1 || i > 10 ) {
     1344#ifdef BNC_DEBUG_BCEP
     1345      emit(newMessage(QString("%1: Block %2 (J) SAT ID is out of range: %3!")
     1346           .arg(_staID)
     1347           .arg(1044,4)
     1348           .arg(i).toLatin1(), true));
     1349#endif
     1350      return false;
     1351    }
    12541352    eph._prn.set('J', i);
    12551353
    12561354    GETBITS(i, 16)
    12571355    i <<= 4;
     1356    if (i < 0 || i > 604784) {
     1357#ifdef BNC_DEBUG_BCEP
     1358      emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
     1359           .arg(_staID)
     1360           .arg(1044,4)
     1361           .arg(eph._prn.toString().c_str())
     1362           .arg(i).toLatin1(), true));
     1363#endif
     1364      return false;
     1365    }
    12581366    eph._TOC.set(i * 1000);
    12591367
     
    12791387    GETBITS(i, 16)
    12801388    i <<= 4;
     1389    if (i < 0 || i > 604784) {
     1390#ifdef BNC_DEBUG_BCEP
     1391      emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
     1392           .arg(_staID)
     1393           .arg(1044,4)
     1394           .arg(eph._prn.toString().c_str())
     1395           .arg(i).toLatin1(), true));
     1396#endif
     1397      return false;
     1398    }
    12811399    eph._TOEsec = i;
    12821400    bncTime t;
     
    12931411    GETBITS(eph._L2Codes, 2)
    12941412    GETBITS(week, 10)
     1413    if (week < 0 || week > 1023) {
     1414#ifdef BNC_DEBUG_BCEP
     1415      emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
     1416           .arg(_staID)
     1417           .arg(1044,4)
     1418           .arg(eph._prn.toString().c_str())
     1419           .arg(week).toLatin1(), true));
     1420#endif
     1421      return false;
     1422    }
    12951423    int numOfRollOvers = int(floor(t.gpsw()/1024.0));
    12961424    week += (numOfRollOvers * 1024);
     
    13361464
    13371465    GETBITS(i, 6)
     1466    if (i < 1 || i > 63 ) {
     1467#ifdef BNC_DEBUG_BCEP
     1468      emit(newMessage(QString("%1: Block %2 (I) PRN# is out of range: %3!")
     1469           .arg(_staID)
     1470           .arg(1041,4)
     1471           .arg(i).toLatin1(), true));
     1472#endif
     1473      return false;
     1474    }
    13381475    eph._prn.set('I', i);
    13391476    GETBITS(week, 10)
     1477    if (week < 0 || week > 1023) {
     1478#ifdef BNC_DEBUG_BCEP
     1479      emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
     1480           .arg(_staID)
     1481           .arg(1041,4)
     1482           .arg(eph._prn.toString().c_str())
     1483           .arg(week).toLatin1(), true));
     1484#endif
     1485      return false;
     1486    }
    13401487    GETFLOATSIGN(eph._clock_bias,     22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
    13411488    GETFLOATSIGN(eph._clock_drift,    16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
     
    13451492    GETBITS(i, 16)
    13461493    i <<= 4;
     1494    if (i < 0 || i > 1048560) {
     1495#ifdef BNC_DEBUG_BCEP
     1496      emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
     1497           .arg(_staID)
     1498           .arg(1041,4)
     1499           .arg(eph._prn.toString().c_str())
     1500           .arg(i).toLatin1(), true));
     1501#endif
     1502      return false;
     1503    }
    13471504    eph._TOC.set(i * 1000);
    13481505    GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 <<  1))
     
    13771534    GETBITS(i, 16)
    13781535    i <<= 4;
     1536    if (i < 0 || i > 1048560) {
     1537#ifdef BNC_DEBUG_BCEP
     1538      emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
     1539           .arg(_staID)
     1540           .arg(1041,4)
     1541           .arg(eph._prn.toString().c_str())
     1542           .arg(i).toLatin1(), true));
     1543#endif
     1544      return false;
     1545    }
    13791546    eph._TOEsec = i;
    13801547    bncTime t;
     
    14281595
    14291596    GETBITS(i, 6)
    1430     eph._prn.set('S', 20 + i);
     1597    if (i < 40 || i > 58 ) {
     1598#ifdef BNC_DEBUG_BCEP
     1599      emit(newMessage(QString("%1: Block %2 (S) PRN# is out of range: %3!")
     1600           .arg(_staID)
     1601           .arg(1043,4)
     1602           .arg(i).toLatin1(), true));
     1603#endif
     1604      return false;
     1605    }
     1606    eph._prn.set('S', 80 + i);
    14311607    GETBITS(eph._IODN, 8)
    14321608    GETBITS(i, 13)
    14331609    i <<= 4;
     1610    if (i < 0 || i > 86384) {
     1611#ifdef BNC_DEBUG_BCEP
     1612      emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
     1613           .arg(_staID)
     1614           .arg(1043,4)
     1615           .arg(eph._prn.toString().c_str())
     1616           .arg(i).toLatin1(), true));
     1617#endif
     1618      return false;
     1619    }
    14341620    eph._TOC.setTOD(i * 1000);
    14351621    GETBITS(i, 4)
     
    14711657  bool decoded = false;
    14721658  uint64_t numbits = 0, bitfield = 0;
    1473   int i;
     1659  int i, week, mnum;
    14741660
    14751661  data += 3; /* header */
     
    14791665  if ((i == 1046 && size == 61) || (i == 1045 && size == 60)) {
    14801666    t_ephGal eph;
    1481 
    14821667    eph._receptDateTime = currentDateAndTimeGPS();
    14831668    eph._receptStaID = _staID;
     
    14851670    eph._inav = (i == 1046);
    14861671    eph._fnav = (i == 1045);
     1672    mnum = i;
    14871673    GETBITS(i, 6)
     1674    if (i < 1 || i > 36 ) { // max. constellation within I/NAV / F/NAV frames is 36
     1675#ifdef BNC_DEBUG_BCEP
     1676      emit(newMessage(QString("%1: Block %2 (E) PRN# is out of range: %3!")
     1677           .arg(_staID)
     1678           .arg(mnum,4)
     1679           .arg(i).toLatin1(), true));
     1680#endif
     1681      return false;
     1682    }
    14881683    eph._prn.set('E', i, eph._inav ? 1 : 0);
    14891684
    1490     GETBITS(eph._TOEweek, 12) //FIXME: roll-over after week 4095!!
     1685    GETBITS(week, 12) //FIXME: roll-over after week 4095!!
     1686    if (week < 0 || week > 4095) {
     1687#ifdef BNC_DEBUG_BCEP
     1688      emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
     1689           .arg(_staID)
     1690           .arg(mnum,4)
     1691           .arg(eph._prn.toString().c_str())
     1692           .arg(week).toLatin1(), true));
     1693#endif
     1694      return false;
     1695    }
     1696    eph._TOEweek = week;
    14911697    GETBITS(eph._IODnav, 10)
    14921698    GETBITS(i, 8)
     
    14941700    GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
    14951701    GETBITSFACTOR(i, 14, 60)
    1496     eph._TOC.set(1024 + eph._TOEweek, i);
     1702    if (i < 0 || i > 604740) {
     1703#ifdef BNC_DEBUG_BCEP
     1704      emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
     1705           .arg(_staID)
     1706           .arg(mnum,4)
     1707           .arg(eph._prn.toString().c_str())
     1708           .arg(i).toLatin1(), true));
     1709#endif
     1710      return false;
     1711    }
     1712    eph._TOC.set(1024 + eph._TOEweek, i);// Period #2 = + 1 x 1024 (has to be determined)
    14971713    GETFLOATSIGN(eph._clock_driftrate, 6, 1.0 / (double )(1 << 30) / (double )(1 << 29))
    14981714    GETFLOATSIGN(eph._clock_drift,    21, 1.0 / (double )(1 << 30) / (double )(1 << 16))
     
    15061722    GETFLOAT(eph._sqrt_A,             32, 1.0 / (double )(1 << 19))
    15071723    GETBITSFACTOR(eph._TOEsec, 14, 60)
     1724    if (i < 0 || i > 604740) {
     1725#ifdef BNC_DEBUG_BCEP
     1726      emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
     1727           .arg(_staID)
     1728           .arg(mnum,4)
     1729           .arg(eph._prn.toString().c_str())
     1730           .arg(i).toLatin1(), true));
     1731#endif
     1732      return false;
     1733    }
    15081734    /* FIXME: overwrite value, copied from old code */
    15091735    eph._TOEsec = eph._TOC.gpssec();
     
    15821808  if (size == 70) {
    15831809    t_ephBDS eph;
    1584     int i;
     1810    int i, week;
    15851811    uint64_t numbits = 0, bitfield = 0;
    15861812
     
    15931819
    15941820    GETBITS(i, 6)
     1821    if (i < 1 || i > 63 ) {
     1822#ifdef BNC_DEBUG_BCEP
     1823      emit(newMessage(QString("%1: Block %2 (C) PRN# is out of range: %3!")
     1824           .arg(_staID)
     1825           .arg(1042,4)
     1826           .arg(i).toLatin1(), true));
     1827#endif
     1828      return false;
     1829    }
    15951830    eph._prn.set('C', i);
    15961831
    1597     GETBITS(eph._BDTweek, 13)
     1832    GETBITS(week, 13)
     1833    if (week < 0 || week > 8191) {
     1834#ifdef BNC_DEBUG_BCEP
     1835      emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
     1836           .arg(_staID)
     1837           .arg(1042,4)
     1838           .arg(eph._prn.toString().c_str())
     1839           .arg(week).toLatin1(), true));
     1840#endif
     1841      return false;
     1842    }
     1843    eph._BDTweek = week;
    15981844    GETBITS(i, 4)
    15991845    eph._URA = accuracyFromIndex(i, eph.type());
     
    16021848    GETBITS(i, 17)
    16031849    i <<= 3;
     1850    if (i < 0 || i > 604792) {
     1851#ifdef BNC_DEBUG_BCEP
     1852      emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
     1853           .arg(_staID)
     1854           .arg(1042,4)
     1855           .arg(eph._prn.toString().c_str())
     1856           .arg(i).toLatin1(), true));
     1857#endif
     1858      return false;
     1859    }
    16041860    eph._TOC.setBDS(eph._BDTweek, i);
    16051861    GETFLOATSIGN(eph._clock_driftrate, 11,  1.0 / (double )(1 << 30) / (double )(1 << 30) / (double )(1 << 6))
     
    16241880    GETBITS(i, 17)
    16251881    i <<= 3;
     1882    if (i < 0 || i > 604792) {
     1883#ifdef BNC_DEBUG_BCEP
     1884      emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
     1885           .arg(_staID)
     1886           .arg(1042,4)
     1887           .arg(eph._prn.toString().c_str())
     1888           .arg(i).toLatin1(), true));
     1889#endif
     1890      return false;
     1891    }
    16261892    eph._TOEsec = i;
    16271893    eph._TOE.setBDS(eph._BDTweek, i);
     
    20822348          _coDecoders.begin().value()->corrGPSEpochTime() : -1;
    20832349}
     2350
     2351
     2352
     2353
Note: See TracChangeset for help on using the changeset viewer.