Changeset 254 in ntrip for trunk/BNC/RTCM


Ignore:
Timestamp:
Oct 18, 2006, 8:46:26 AM (18 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC/RTCM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM/RTCM2.cpp

    r253 r254  
    66//
    77//   Module for extraction of RTCM2 messages
     8//
     9// References:
     10//
     11//   RTCM 10402.3 Recommended Standards for Differential GNSS (Global
     12//     Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
     13//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
     14//     Services, Alexandria, Virgina (2001).
     15//   ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
     16//     Revison C; 25 Sept. 1997; Arinc Research Corp., El Segundo (1997).
     17//   Jensen M.; RTCM2ASC Documentation;
     18//     URL http://kom.aau.dk/~borre/masters/receiver/rtcm2asc.htm;
     19//     last accessed 17 Sep. 2006
     20//   Sager J.; Decoder for RTCM SC-104 data from a DGPS beacon receiver;
     21//     URL http://www.wsrcc.com/wolfgang/ftp/rtcm-0.3.tar.gz;
     22//     last accessed 17 Sep. 2006
    823//
    924// Notes:
     
    2136//   2006/10/14  LMV  Exception handling
    2237//   2006/10/17  OMO  Removed obsolete check of multiple message indicator
     38//   2006/10/17  OMO  Fixed parity handling
    2339//
    2440// (c) DLR/GSOC
     
    2642//------------------------------------------------------------------------------
    2743
     44#include <bitset>
    2845#include <cmath>
    2946#include <fstream>
     
    3552#include "RTCM2.h"
    3653
     54// Activate (1) or deactivate (0) debug output for tracing parity errors and
     55// undersized packets in get(Unsigned)Bits
     56
     57#define DEBUG 0   
    3758
    3859using namespace std;
     
    166187        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
    167188
    168   return ( (W!=0) && ((W &0x3f) == p));
     189  return ( (W & 0x3f) == p);
    169190
    170191};
     
    256277  buf.erase(0,5);
    257278
     279#if (DEBUG>0)
     280  if (!validParity()) {
     281    cout << "Parity error "
     282         << bitset<32>(all()) << endl;
     283  };
     284#endif
    258285  failure = false;
    259286
     
    272299  };
    273300
     301#if (DEBUG>0)
     302  if (!validParity()) {
     303    cout << "Parity error "
     304         << bitset<32>(all()) << endl;
     305  };
     306#endif
    274307  failure = false;
    275308
     
    299332  buf.erase(0,i);
    300333
     334#if (DEBUG>0)
     335  if (!validParity()) {
     336    cout << "Parity error "
     337         << bitset<32>(all()) << endl;
     338  };
     339#endif
    301340  failure = false;
    302341
     
    317356  };
    318357
     358#if (DEBUG>0)
     359  if (!validParity()) {
     360    cout << "Parity error "
     361         << bitset<32>(all()) << endl;
     362  };
     363#endif
    319364  failure = false;
    320365
     
    383428  W.getHeader(buf);
    384429  H1 = W.value();
    385   if (W.fail()) { clear(); W=W_old; buf=buf_old; return; }
     430  if (W.fail()) { clear(); W=W_old; buf=buf_old; return; };
     431  if (!W.validParity()) { clear(); return; };
    386432 
    387433  W.get(buf);       
    388434  H2 = W.value();
    389   if (W.fail()) { clear(); W=W_old; buf=buf_old; return; }
     435  if (W.fail()) { clear(); W=W_old; buf=buf_old; return; };
     436  if (!W.validParity()) { clear(); return; };
    390437
    391438  n = nDataWords();
     
    394441    W.get(buf);
    395442    DW[i] = W.value();
    396     if (W.fail()) { clear(); W=W_old; buf=buf_old; return; }
     443    if (W.fail()) { clear(); W=W_old; buf=buf_old; return; };
     444    if (!W.validParity()) { clear(); return; };
    397445  };
    398446
     
    412460  W.getHeader(inp);
    413461  H1 = W.value();
    414   if (W.fail()) { clear(); return; }
     462  if (W.fail() || !W.validParity()) { clear(); return; }
    415463 
    416464  W.get(inp);       
    417465  H2 = W.value();
    418   if (W.fail()) { clear(); return; }
     466  if (W.fail() || !W.validParity()) { clear(); return; }
    419467
    420468  n = nDataWords();
     
    423471    W.get(inp);
    424472    DW[i] = W.value();
    425     if (W.fail()) { clear(); return; }
     473    if (W.fail() || !W.validParity()) { clear(); return; }
    426474  };
    427475
     
    433481// Input operator
    434482//
    435 // Reads an RTCM3 packet from the input stream.
     483// Reads an RTCM2 packet from the input stream.
    436484//
    437485
     
    509557 
    510558  if ( 24*DW.size() < start+n-1 ) {
     559#if (DEBUG>0)
     560    cerr << "Debug output RTCM2packet::getUnsignedBits" << endl
     561         << "  P.msgType:    " << setw(5) << msgType()    << endl
     562         << "  P.nDataWords: " << setw(5) << nDataWords() << endl
     563         << "  start:        " << setw(5) << start        << endl
     564         << "  n:            " << setw(5) << n            << endl
     565         << "  P.H1:         " << setw(5) << bitset<32>(H1) << endl
     566         << "  P.H2:         " << setw(5) << bitset<32>(H2) << endl
     567         << endl
     568         << flush;
     569#endif
    511570    throw("Error: Packet too short in RTCM2packet::getUnsignedBits");
    512571  }
     
    558617 
    559618  if ( 24*DW.size() < start+n-1 ) {
     619#if (DEBUG>0)
     620    cerr << "Debug output RTCM2packet::getUnsignedBits" << endl
     621         << "  P.msgType:    " << setw(5) << msgType()    << endl
     622         << "  P.nDataWords: " << setw(5) << nDataWords() << endl
     623         << "  start:        " << setw(5) << start        << endl
     624         << "  n:            " << setw(5) << n            << endl
     625         << "  P.H1:         " << setw(5) << bitset<32>(H1) << endl
     626         << "  P.H2:         " << setw(5) << bitset<32>(H2) << endl
     627         << endl
     628         << flush;
     629#endif
    560630    throw("Error: Packet too short in RTCM2packet::getBits");
    561631  }
  • trunk/BNC/RTCM/RTCM2.h

    r253 r254  
    1818//     URL http://kom.aau.dk/~borre/masters/receiver/rtcm2asc.htm;
    1919//     last accessed 17 Sep. 2006
    20 //   Sager J.;Decoder for RTCM SC-104 data from a DGPS beacon receiver;
     20//   Sager J.; Decoder for RTCM SC-104 data from a DGPS beacon receiver;
    2121//     URL http://www.wsrcc.com/wolfgang/ftp/rtcm-0.3.tar.gz;
    2222//     last accessed 17 Sep. 2006
Note: See TracChangeset for help on using the changeset viewer.