Changeset 1429 in ntrip for trunk/BNC/GPSS
- Timestamp:
- Jan 3, 2009, 10:54:32 AM (16 years ago)
- Location:
- trunk/BNC/GPSS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/GPSS/gpssDecoder.cpp
r1427 r1429 1 1 \ 2 2 /* ------------------------------------------------------------------------- 3 3 * BKG NTRIP Client … … 57 57 errmsg.clear(); 58 58 59 if (_mode == MODE_SEARCH) { 60 _buffer.clear(); 61 } 62 _buffer.append(data, dataLen); 59 _buffer += QByteArray(data, dataLen); 63 60 64 for (;;) { 61 int iBeg; 62 while ( (iBeg = _buffer.indexOf(0x02)) != -1) { 63 _buffer = _buffer.mid(iBeg); 65 64 66 if (_buffer.size() < 1) { 67 _mode = MODE_SEARCH; 68 return success; 65 // Record Size 66 // ----------- 67 int recordSize; 68 if (_buffer.length() >= int(2 + sizeof(recordSize)) && 69 ( char(_buffer[1]) == 0x00 || char(_buffer[1]) == 0x01) ) { 70 memcpy(&recordSize, _buffer.data()+2, sizeof(recordSize)); 71 } 72 else { 73 break; 74 } 75 76 // Observations 77 // ------------ 78 if (char(_buffer[1]) == 0x00) { 79 EPOCHHEADER epochHdr; 80 if (_buffer.length() >= int(2 + sizeof(recordSize) + sizeof(epochHdr))) { 81 memcpy(&epochHdr, _buffer.data() + 2 + sizeof(recordSize), 82 sizeof(epochHdr)); 83 84 if (_buffer.length() >= int(2 + sizeof(recordSize) + sizeof(epochHdr) + 85 epochHdr.n_svs * sizeof(t_obsInternal))) { 86 for (int is = 1; is <= epochHdr.n_svs; is++) { 87 t_obs* obs = new t_obs(); 88 memcpy(&(obs->_o), _buffer.data(), sizeof(t_obsInternal)); 89 _obsList.push_back(obs); 90 } 91 } 92 } 69 93 } 70 94 71 if (_mode == MODE_SEARCH) { 72 if (_buffer[0] == 0x02) { 73 _mode = MODE_TYPE; 95 // Ephemeris 96 // --------- 97 else if (char(_buffer[1]) == 0x01) { 98 if (_buffer.length() >= int(2+sizeof(recordSize)+ sizeof(gpsephemeris))){ 99 gpsephemeris* gpsEph = new gpsephemeris; 100 memcpy(gpsEph, _buffer.data(), sizeof(gpsephemeris)); 101 emit newGPSEph(gpsEph); 74 102 } 75 else {76 _mode = MODE_SEARCH;77 }78 _buffer.erase(0,1);79 }80 81 else if (_mode == MODE_TYPE) {82 if (_buffer[0] == 0x00) {83 _mode = MODE_EPOCH;84 } else if (_buffer[0] == 0x01) {85 _mode = MODE_EPH;86 } else {87 _mode = MODE_SEARCH;88 }89 _buffer.erase(0,1);90 }91 92 else if (_mode == MODE_EPOCH || _mode == MODE_EPH) {93 int recordSize;94 if (_buffer.size() < sizeof(recordSize)) {95 _mode = MODE_SEARCH;96 return success;97 }98 memcpy(&recordSize, _buffer.data(), sizeof(recordSize));99 if (_mode == MODE_EPOCH) {100 _mode = MODE_EPOCH_BODY;101 }102 if (_mode == MODE_EPH) {103 _mode = MODE_EPH_BODY;104 }105 _buffer.erase(0,sizeof(recordSize));106 }107 108 else if (_mode == MODE_EPOCH_BODY) {109 EPOCHHEADER epochHdr;110 if (_buffer.size() < sizeof(epochHdr)) {111 _mode = MODE_SEARCH;112 return success;113 }114 memcpy(&epochHdr, _buffer.data(), sizeof(epochHdr));115 _buffer.erase(0,sizeof(epochHdr));116 if (_buffer.size() < epochHdr.n_svs * sizeof(t_obsInternal)) {117 _mode = MODE_SEARCH;118 return success;119 }120 for (int is = 1; is <= epochHdr.n_svs; is++) {121 t_obs* obs = new t_obs();122 memcpy(&(obs->_o), _buffer.data(), sizeof(t_obsInternal));123 _obsList.push_back(obs);124 _buffer.erase(0, sizeof(t_obsInternal));125 }126 _mode = MODE_EPOCH_CRC;127 }128 129 else if (_mode == MODE_EPH_BODY) {130 if (_buffer.size() < sizeof(gpsephemeris)) {131 _mode = MODE_SEARCH;132 return success;133 }134 gpsephemeris* gpsEph = new gpsephemeris;135 memcpy(gpsEph, _buffer.data(), sizeof(gpsephemeris));136 emit newGPSEph(gpsEph);137 _buffer.erase(0, sizeof(gpsephemeris));138 _mode = MODE_EPH_CRC;139 103 } 140 104 141 105 else { 142 _buffer.erase(0,1); 143 _mode = MODE_SEARCH; 106 _buffer == _buffer.mid(1); 144 107 } 145 108 } -
trunk/BNC/GPSS/gpssDecoder.h
r1425 r1429 21 21 22 22 private: 23 int 24 std::string_buffer;23 int _mode; 24 QByteArray _buffer; 25 25 } ; 26 26
Note:
See TracChangeset
for help on using the changeset viewer.