Changeset 66 in ntrip


Ignore:
Timestamp:
Aug 24, 2006, 8:45:44 PM (18 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTIGS/rtigs.cpp

    r63 r66  
    3434void rtigs::Decode(char* buffer, int bufLen) {
    3535
    36   unsigned char* lBuffer = (unsigned char*) buffer;
     36  // Append the incomming data to the internal buffer
     37  // ------------------------------------------------
     38  _buffer.append( QByteArray(buffer, bufLen) );
    3739
    3840  // Find the beginning of the message
    3941  // ---------------------------------
    40   size_t sz = sizeof(unsigned short);
    41   bool   found = false;
    42   size_t ii;
    43 
    44   for (ii = 0; bufLen > sz && ii < bufLen - sz; ii += sz) {
     42  bool found = false;
     43  for (int ii = 0; ii < _buffer.size(); ii++) {
    4544    unsigned short xx;
    46     memcpy( (void*) &xx, &lBuffer[ii], sz);
    47     SwitchBytes( (char*) &xx, sz);
     45    memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
     46    SwitchBytes( (char*) &xx, sizeof(xx) );
    4847    if (xx == 200) {
     48      _buffer = _buffer.mid(ii);
     49      cout << "Message found at " << ii << endl;
    4950      found = true;
    5051      break;
     
    5354  if (! found) {
    5455    cout << "Message not found\n";
     56    _buffer.clear();
    5557    return;
    5658  }
    57   else {
    58     cout << "Message found at " << ii << endl;
     59
     60  unsigned char* p_buf = (unsigned char*) _buffer.data(); 
     61
     62  unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
     63  unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
     64  ////  unsigned short statID   = _GPSTrans.GetRTIGSHdrStaID(p_buf);
     65
     66  cout << "numbytes = " << numbytes << endl;
     67
     68  // Not enough new data, store it into the internal buffer and return
     69  // -----------------------------------------------------------------
     70  if (_buffer.size() < numbytes) {
     71    return;
    5972  }
    60 
    61   unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(&lBuffer[ii]);
    62   unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(&lBuffer[ii]);
    63   unsigned short statID   = _GPSTrans.GetRTIGSHdrStaID(&lBuffer[ii]);
    6473
    6574  if (messType == 200) {
    6675    RTIGSO_T       rtigs_obs;
    67     short retval = _GPSTrans.Decode_RTIGS_Obs(&lBuffer[ii], numbytes ,
     76    short retval = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes ,
    6877                                              rtigs_obs);
    6978    if (retval >= 1) {
     
    7180    }
    7281  }
     82
     83  // Unprocessed bytes remain in buffer
     84  // ----------------------------------
     85  _buffer = _buffer.mid(numbytes);
    7386}
Note: See TracChangeset for help on using the changeset viewer.