Changeset 9861 in ntrip for trunk/BNC/src/upload


Ignore:
Timestamp:
Oct 24, 2022, 11:06:42 AM (2 years ago)
Author:
stuerze
Message:

minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/upload/bncrtnetuploadcaster.cpp

    r9846 r9861  
    274274  if (iEpoBeg == -1) {
    275275    _rtnetStreamBuffer.clear();
    276     emit(newMessage(
    277           "bncRtnetUploadCaster: no Epoch line found " + _casterID.toLatin1(), false));
     276    emit(newMessage("bncRtnetUploadCaster: no Epoch line found " + _casterID.toLatin1(), false));
    278277    return;
    279278  }
    280 
    281   int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
    282   if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) { // are there two epoch lines in buffer?
    283     _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
     279  _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
     280
     281  int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end   of last epoch
     282  if (iEpoEnd == -1) {
     283    emit(newMessage("bncRtnetUploadCaster: no EOE found " + _casterID.toLatin1(), false));
     284    return;
    284285  }
    285286  else {
    286     _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
    287   }
    288 
    289   int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
    290   if (iEpoEnd == -1) {
    291     _rtnetStreamBuffer.clear();
    292     emit(newMessage(
    293           "bncRtnetUploadCaster: no EOE found " + _casterID.toLatin1(), false));
     287    lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
     288    _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
     289  }
     290
     291  if (lines.size() < 2) {
     292      emit(newMessage("bncRtnetUploadCaster: less than 2 lines to decode " + _casterID.toLatin1(), false));
    294293    return;
    295294  }
    296295
    297   while (_rtnetStreamBuffer.count('*') > 1) { // is there more than 1 epoch line in buffer?
    298     emit(newMessage(
    299           "bncRtnetUploadCaster: more than 1 epoch line in buffer " + _rtnetStreamBuffer.count('*'), false));
    300     QString rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
    301     int nextEpoch = rtnetStreamBuffer.indexOf('*');
    302     if      (nextEpoch != -1 && nextEpoch < iEpoEnd) {
    303       _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
    304     }
    305     else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
    306       break;
    307     }
    308   }
    309 
    310   lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
    311 
    312   _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
    313 
    314   if (lines.size() < 2) {
    315     emit(newMessage(
    316           "bncRtnetUploadCaster: less than 2 lines to decode " + _casterID.toLatin1(), false));
    317     return;
     296  // Keep the last unfinished line in buffer
     297  // ---------------------------------------
     298  int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
     299  if (iLastEOL != -1) {
     300    _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
    318301  }
    319302
Note: See TracChangeset for help on using the changeset viewer.