Index: trunk/BNC/src/PPP/pppRun.cpp
===================================================================
--- trunk/BNC/src/PPP/pppRun.cpp	(revision 5988)
+++ trunk/BNC/src/PPP/pppRun.cpp	(revision 5989)
@@ -296,4 +296,15 @@
     }
 
+    if (!output._error) {
+      QString rmcStr = nmeaRMC(output);
+      QString ggaStr = nmeaGGA(output);
+      if (_nmeaFile) {
+        _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
+        _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
+      }
+      emit newNMEAstr(staID, rmcStr.toAscii());
+      emit newNMEAstr(staID, ggaStr.toAscii());
+    }
+
     emit newMessage(QByteArray(log.str().c_str()), true);
   }
@@ -504,2 +515,89 @@
   _stopFlag = true;
 }
+
+//  
+////////////////////////////////////////////////////////////////////////////
+QString t_pppRun::nmeaRMC(const t_output& output) const {
+
+  double ell[3]; 
+  xyz2ell(output._xyzRover, ell);
+  double phiDeg = ell[0] * 180 / M_PI;
+  double lamDeg = ell[1] * 180 / M_PI;
+
+  char phiCh = 'N';
+  if (phiDeg < 0) {
+    phiDeg = -phiDeg;
+    phiCh  =  'S';
+  }   
+  char lamCh = 'E';
+  if (lamDeg < 0) {
+    lamDeg = -lamDeg;
+    lamCh  =  'W';
+  }   
+
+  string datestr = output._epoTime.datestr(0); // yyyymmdd
+
+  ostringstream strRMC;
+  strRMC.setf(ios::fixed);
+  strRMC << "GPRMC," 
+         << output._epoTime.timestr(0,0) << ",A,"
+         << setw(2) << setfill('0') << int(phiDeg) 
+         << setw(6) << setprecision(3) << setfill('0') 
+         << fmod(60*phiDeg,60) << ',' << phiCh << ','
+         << setw(3) << setfill('0') << int(lamDeg) 
+         << setw(6) << setprecision(3) << setfill('0') 
+         << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
+         << datestr[6] << datestr[7] << datestr[4] << datestr[5]
+         << datestr[2] << datestr[3] << ",,";
+
+  QString nmStr(strRMC.str().c_str());
+  unsigned char XOR = 0;
+  for (int ii = 0; ii < nmStr.length(); ii++) {
+    XOR ^= (unsigned char) nmStr[ii].toAscii();
+  }
+
+  return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
+}
+
+//  
+////////////////////////////////////////////////////////////////////////////
+QString t_pppRun::nmeaGGA(const t_output& output) const {
+
+  double ell[3]; 
+  xyz2ell(output._xyzRover, ell);
+  double phiDeg = ell[0] * 180 / M_PI;
+  double lamDeg = ell[1] * 180 / M_PI;
+
+  char phiCh = 'N';
+  if (phiDeg < 0) {
+    phiDeg = -phiDeg;
+    phiCh  =  'S';
+  }   
+  char lamCh = 'E';
+  if (lamDeg < 0) {
+    lamDeg = -lamDeg;
+    lamCh  =  'W';
+  }   
+
+  ostringstream strGGA;
+  strGGA.setf(ios::fixed);
+  strGGA << "GPGGA," 
+         << output._epoTime.timestr(0,0) << ','
+         << setw(2) << setfill('0') << int(phiDeg) 
+         << setw(10) << setprecision(7) << setfill('0') 
+         << fmod(60*phiDeg,60) << ',' << phiCh << ','
+         << setw(3) << setfill('0') << int(lamDeg) 
+         << setw(10) << setprecision(7) << setfill('0') 
+         << fmod(60*lamDeg,60) << ',' << lamCh 
+         << ",1," << setw(2) << setfill('0') << output._numSat << ','
+         << setw(3) << setprecision(1) << output._pDop << ','
+         << setprecision(3) << ell[2] << ",M,0.0,M,,";
+
+  QString nmStr(strGGA.str().c_str());
+  unsigned char XOR = 0;
+  for (int ii = 0; ii < nmStr.length(); ii++) {
+    XOR ^= (unsigned char) nmStr[ii].toAscii();
+  }
+
+  return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
+}
Index: trunk/BNC/src/PPP/pppRun.h
===================================================================
--- trunk/BNC/src/PPP/pppRun.h	(revision 5988)
+++ trunk/BNC/src/PPP/pppRun.h	(revision 5989)
@@ -54,4 +54,7 @@
   };
 
+  QString nmeaRMC(const t_output& output) const;
+  QString nmeaGGA(const t_output& output) const;
+
   QMutex                 _mutex;
   const t_pppOptions*    _opt;
@@ -61,12 +64,11 @@
   double                 _lastClkCorrValue[t_prn::MAXPRN+1];
   bncTime                _lastClkCorrTime;
-
-  t_rnxObsFile* _rnxObsFile;
-  t_rnxNavFile* _rnxNavFile;
-  t_corrFile*   _corrFile;
-  int           _speed;
-  bool          _stopFlag;
-  bncoutf*      _logFile;
-  bncoutf*      _nmeaFile;
+  t_rnxObsFile*          _rnxObsFile;
+  t_rnxNavFile*          _rnxNavFile;
+  t_corrFile*            _corrFile;
+  int                    _speed;
+  bool                   _stopFlag;
+  bncoutf*               _logFile;
+  bncoutf*               _nmeaFile;
 };
 
