Index: /trunk/BNC/src/upload/bncrtnetuploadcaster.cpp
===================================================================
--- /trunk/BNC/src/upload/bncrtnetuploadcaster.cpp	(revision 9867)
+++ /trunk/BNC/src/upload/bncrtnetuploadcaster.cpp	(revision 9868)
@@ -270,6 +270,7 @@
   // Select buffer part that contains last epoch
   // -------------------------------------------
-  QStringList lines;
-  int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*');   // begin of last epoch
+
+  // Find the begin of last epoch
+  int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*');
   if (iEpoBeg == -1) {
     _rtnetStreamBuffer.clear();
@@ -277,31 +278,63 @@
     return;
   }
-  _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
-
-  int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end   of last epoch
+
+  // Find the begin of the first epoch
+  int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
+  if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) {
+    _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
+  }
+  else {
+    _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
+  }
+
+  // Find End of the last epoch
+  int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE");
   if (iEpoEnd == -1) {
+    _rtnetStreamBuffer.clear();
     emit(newMessage("bncRtnetUploadCaster: no EOE found " + _casterID.toLatin1(), false));
     return;
   }
-  else {
-    lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
-    _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
-  }
+
+  // If there is there more than 1 epoch line in the buffer
+  while (_rtnetStreamBuffer.count('*') > 1) {
+    emit(newMessage("bncRtnetUploadCaster: more than 1 epoch in buffer: " + _rtnetStreamBuffer.count('*') , false));
+    QString rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
+    int nextEpoch = rtnetStreamBuffer.indexOf('*');
+    cout << "=============" << endl;
+    cout << "nextEpoch: " << nextEpoch << endl;
+    cout << "iEpoEnd  : " << iEpoEnd   << endl;
+    if      (nextEpoch != -1 && nextEpoch < iEpoEnd) {
+      _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
+      cout <<  _rtnetStreamBuffer.toStdString().c_str() << endl;
+    }
+    else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
+      break;
+    }
+    else {
+      cout <<  _rtnetStreamBuffer.toStdString().c_str() << endl;
+    }
+  }
+
+  QStringList lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
+
+  _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
 
   if (lines.size() < 2) {
-      emit(newMessage("bncRtnetUploadCaster: less than 2 lines to decode " + _casterID.toLatin1(), false));
+    emit(newMessage(
+          "bncRtnetUploadCaster: less than 2 lines to decode " + _casterID.toLatin1(), false));
     return;
   }
 
-  // Keep the last unfinished line in buffer
-  // ---------------------------------------
-  int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
-  if (iLastEOL != -1) {
-    _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
-  }
+  decodeRtnetEpoch(lines);
+
+}
+
+//
+////////////////////////////////////////////////////////////////////////////
+void bncRtnetUploadCaster::decodeRtnetEpoch(QStringList epochLines) {
 
   // Read first line (with epoch time)
   // ---------------------------------
-  QTextStream in(lines[0].toLatin1());
+  QTextStream in(epochLines[0].toLatin1());
   QString hlp;
   int year, month, day, hour, min;
@@ -398,5 +431,5 @@
   phasebias.UpdateInterval = ephUpdInd;
 
-  for (int ii = 1; ii < lines.size(); ii++) {
+  for (int ii = 1; ii < epochLines.size(); ii++) {
     QString key;  // prn or key VTEC, IND (phase bias indicators)
     double rtnUra = 0.0; // [m]
@@ -408,5 +441,5 @@
     t_prn prn;
 
-    QTextStream in(lines[ii].toLatin1());
+    QTextStream in(epochLines[ii].toLatin1());
 
     in >> key;
@@ -951,8 +984,6 @@
   }
 
-  _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias
-      + hlpBufferVtec + '\0';
+  _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias + hlpBufferVtec + '\0';
 }
-
 //
 ////////////////////////////////////////////////////////////////////////////
Index: /trunk/BNC/src/upload/bncrtnetuploadcaster.h
===================================================================
--- /trunk/BNC/src/upload/bncrtnetuploadcaster.h	(revision 9867)
+++ /trunk/BNC/src/upload/bncrtnetuploadcaster.h	(revision 9868)
@@ -43,5 +43,5 @@
                         struct SsrCorr::ClockOrbit::SatData* sd,
                         QString& outLine);
-
+  void decodeRtnetEpoch(QStringList epochLines);
   bool corrIsOutOfRange(struct SsrCorr::ClockOrbit::SatData* sd);
 
