Changeset 66 in ntrip
- Timestamp:
- Aug 24, 2006, 8:45:44 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTIGS/rtigs.cpp
r63 r66 34 34 void rtigs::Decode(char* buffer, int bufLen) { 35 35 36 unsigned char* lBuffer = (unsigned char*) buffer; 36 // Append the incomming data to the internal buffer 37 // ------------------------------------------------ 38 _buffer.append( QByteArray(buffer, bufLen) ); 37 39 38 40 // Find the beginning of the message 39 41 // --------------------------------- 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++) { 45 44 unsigned short xx; 46 memcpy( (void*) &xx, & lBuffer[ii], sz);47 SwitchBytes( (char*) &xx, s z);45 memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) ); 46 SwitchBytes( (char*) &xx, sizeof(xx) ); 48 47 if (xx == 200) { 48 _buffer = _buffer.mid(ii); 49 cout << "Message found at " << ii << endl; 49 50 found = true; 50 51 break; … … 53 54 if (! found) { 54 55 cout << "Message not found\n"; 56 _buffer.clear(); 55 57 return; 56 58 } 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; 59 72 } 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]);64 73 65 74 if (messType == 200) { 66 75 RTIGSO_T rtigs_obs; 67 short retval = _GPSTrans.Decode_RTIGS_Obs( &lBuffer[ii], numbytes ,76 short retval = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes , 68 77 rtigs_obs); 69 78 if (retval >= 1) { … … 71 80 } 72 81 } 82 83 // Unprocessed bytes remain in buffer 84 // ---------------------------------- 85 _buffer = _buffer.mid(numbytes); 73 86 }
Note:
See TracChangeset
for help on using the changeset viewer.