Changeset 1368 in ntrip
- Timestamp:
- Dec 27, 2008, 11:42:31 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncgetthread.cpp
r1367 r1368 503 503 _socket->waitForReadyRead(_timeOut); 504 504 nBytes = _socket->bytesAvailable(); 505 cout << "nBytes " << nBytes << endl; 505 506 } 506 507 else if (_rawInpFile) { … … 512 513 emit newBytes(_staID, nBytes); 513 514 514 char* data = new char[nBytes];515 QByteArray data; 515 516 516 517 if (_socket) { 517 _socket->read( data,nBytes);518 data = _socket->read(nBytes); 518 519 } 519 520 else if (_rawInpFile) { 520 nBytes= _rawInpFile->read(data,nBytes);521 if ( nBytes <= 0) {521 data = _rawInpFile->read(nBytes); 522 if (data.isEmpty()) { 522 523 cout << "no more data" << endl; 523 524 ::exit(0); … … 526 527 527 528 if (_rawOutFile) { 528 _rawOutFile->write(data , nBytes);529 _rawOutFile->write(data); 529 530 _rawOutFile->flush(); 530 531 } 531 532 532 533 if (_serialPort) { 533 _serialPort->write(data , nBytes);534 _serialPort->write(data); 534 535 //// _serialPort->flush(); 535 536 } … … 537 538 if (_inspSegm<1) { 538 539 vector<string> errmsg; 539 _decoder->Decode(data , nBytes, errmsg);540 _decoder->Decode(data.data(), data.size(), errmsg); 540 541 #ifdef DEBUG_RTCM2_2021 541 542 for (unsigned ii = 0; ii < errmsg.size(); ii++) { … … 553 554 if (decode) { 554 555 vector<string> errmsg; 555 if ( _decoder->Decode(data , nBytes, errmsg) == success ) {556 if ( _decoder->Decode(data.data(), data.size(), errmsg) == success ) { 556 557 numSucc += 1; 557 558 } … … 648 649 } 649 650 650 delete [] data;651 652 653 651 // RTCM scan output 654 652 // ---------------- -
trunk/BNC/bncsocket.cpp
r1367 r1368 17 17 #include <iostream> 18 18 #include <iomanip> 19 20 #include <string.h>21 19 22 20 #include "bncsocket.h" … … 145 143 // 146 144 //////////////////////////////////////////////////////////////////////////// 147 qint64bncSocket::read(char* data,qint64 maxlen) {148 if (_http) { 149 strncpy(data,_buffer.data(), maxlen);150 _buffer = _buffer.right(_buffer.size()-max len);151 return maxlen;152 } 153 else if (_socket) { 154 return _socket->read( data, maxlen);155 } 156 else { 157 return -1;145 QByteArray bncSocket::read(qint64 maxSize) { 146 if (_http) { 147 QByteArray ret = _buffer.left(maxSize); 148 _buffer = _buffer.right(_buffer.size()-maxSize); 149 return ret; 150 } 151 else if (_socket) { 152 return _socket->read(maxSize); 153 } 154 else { 155 return ""; 158 156 } 159 157 } -
trunk/BNC/bncsocket.h
r1364 r1368 17 17 QByteArray readLine(); 18 18 void waitForReadyRead(int msecs = 30000); 19 qint64 read(char *data,qint64 maxlen);19 QByteArray read(qint64 maxSize); 20 20 QAbstractSocket::SocketState state() const; 21 21
Note:
See TracChangeset
for help on using the changeset viewer.