<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>objects/patience.cpp</filename>
    </added>
    <added>
      <filename>objects/patience.h</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -94,7 +94,7 @@ void GUI_Channel::render(wxDC&amp; dc)
 
 		tChannel-&gt;SetDefaultStyle(style);
 
-		if(pchan-&gt;count &gt; 1000)
+		if(pchan-&gt;count &gt; 2000)
 		{
 
 			str2.Clear();</diff>
      <filename>gse/src/gui_channel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -47,6 +47,7 @@ EXTERN class SV_Select		*pSV_Select;					//!&lt; Contains the channels and drives t
 EXTERN class Telemetry		*pTelemetry;					//!&lt; Simple ncurses interface
 EXTERN class Commando		*pCommando;						//!&lt; Process and execute commands
 EXTERN class GPS_Source		*pSource;						//!&lt; Get the GPS data from somewhere
+EXTERN class Patience		*pPatience;						//!&lt; Watchdog for GPS Source
 /*----------------------------------------------------------------------------------------------*/
 
 /*----------------------------------------------------------------------------------------------*/</diff>
      <filename>includes/globals.h</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,7 @@
 #include &quot;commando.h&quot;			//!&lt; Command interface
 #include &quot;sv_select.h&quot;			//!&lt; Drives acquisition/reacquisition process
 #include &quot;gps_source.h&quot;			//!&lt; Get GPS IF data from where?
+#include &quot;patience.h&quot;
 /*----------------------------------------------------------------------------------------------*/
 
 
@@ -290,11 +291,11 @@ int32 Object_Init(void)
 	for(lcv = 0; lcv &lt; MAX_CHANNELS; lcv++)
 		pChannels[lcv] = new Channel(lcv);
 
-	/* Get data from either the USRP or disk */
+	/* Get data from either the USRP/GN3S/disk */
 	pFIFO = new FIFO;
 
-	/* Draw the GPS data from somewhere */
-	pSource = new GPS_Source(&amp;gopt);
+	/* Startup Watchdog */
+	pPatience = new Patience;
 
 	pCorrelator = new Correlator();
 
@@ -393,6 +394,11 @@ int32 Thread_Init(void)
 	/* Start up the FIFO */
 	pFIFO-&gt;Start();
 
+	sleep(1);
+
+	/* Start up the Watchdog */
+	pPatience-&gt;Start();
+
 	return(1);
 
 }</diff>
      <filename>main/init.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,7 @@
 #include &quot;commando.h&quot;			//!&lt; Command interface
 #include &quot;sv_select.h&quot;			//!&lt; Drives acquisition/reacquisition process
 #include &quot;gps_source.h&quot;			//!&lt; Get GPS data
+#include &quot;patience.h&quot;
 /*----------------------------------------------------------------------------------------------*/
 
 
@@ -50,6 +51,9 @@ void Thread_Shutdown(void)
 	/* Start the keyboard thread to handle user input from stdio */
 	pKeyboard-&gt;Stop();
 
+	/* Stop the WatchDog */
+	pPatience-&gt;Stop();
+
 	/* Stop the FIFO */
 	pFIFO-&gt;Stop();
 
@@ -132,11 +136,11 @@ void Object_Shutdown(void)
 	delete pAcquisition;
 	delete pEphemeris;
 	delete pFIFO;
-	delete pSource;
 	delete pSV_Select;
 	delete pTelemetry;
 	delete pPVT;
 	delete pCommando;
+	delete pPatience;
 
 }
 /*----------------------------------------------------------------------------------------------*/</diff>
      <filename>main/shutdown.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -422,12 +422,12 @@ void Channel::FrequencyLock()
 void Channel::DLL()
 {
 
-	float code_err;
-	float ep, lp, sp;
+	double code_err;
+	double ep, lp, sp;
 
-	ep = sqrt(float(P[0]));
-	lp = sqrt(float(P[2]));
-	sp = sqrt(float(P_avg));
+	ep = sqrt(double(P[0]));
+	lp = sqrt(double(P[2]));
+	sp = sqrt(double(P[2] + P[0]));
 
 	code_err  = (ep - lp) / sp;
 
@@ -452,10 +452,10 @@ void Channel::DLL()
 void Channel::PLL()
 {
 
-	float df;
-	float dp;
-	float dot;
-	float cross;
+	double df;
+	double dp;
+	double dot;
+	double cross;
 	int32 I1, I2, Q1, Q2, lcv;
 
 	df = dp = 0;
@@ -479,7 +479,7 @@ void Channel::PLL()
 	/* PLL discriminator */
 	if(I[1] != 0)
 	{
-		dp = atan((float)Q[1]/(float)I[1])/TWO_PI;
+		dp = atan((double)Q[1]/(double)I[1])/TWO_PI;
 	}
 
 	/* Lock indicators */</diff>
      <filename>objects/channel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -33,6 +33,10 @@ void *FIFO_Thread(void *_arg)
 
 	FIFO *aFIFO = pFIFO;
 
+	/* This thread must be cancellable by the watchdog */
+	pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
 	while(grun)
 	{
 		aFIFO-&gt;Import();
@@ -60,6 +64,7 @@ void FIFO::Start()
 /*----------------------------------------------------------------------------------------------*/
 FIFO::FIFO():Threaded_Object(&quot;FIFTASK&quot;)
 {
+
 	int32 lcv;
 
 	/* Create the buffer */
@@ -79,6 +84,9 @@ FIFO::FIFO():Threaded_Object(&quot;FIFTASK&quot;)
 	sem_init(&amp;sem_full, NULL, 0);
 	sem_init(&amp;sem_empty, NULL, FIFO_DEPTH);
 
+	pSource = NULL;
+	ResetSource();
+
 	if(gopt.verbose)
 		fprintf(stdout,&quot;Creating FIFO\n&quot;);
 
@@ -96,6 +104,9 @@ FIFO::~FIFO()
 
 	delete [] buff;
 
+	if(pSource != NULL)
+		delete pSource;
+
 	if(gopt.verbose)
 		fprintf(stdout,&quot;Destructing FIFO\n&quot;);
 
@@ -110,7 +121,8 @@ void FIFO::Import()
 	IncStartTic();
 
 	/* Read from the GPS source */
-	pSource-&gt;Read(head);
+	if(pSource != NULL)
+		pSource-&gt;Read(head);
 
 	Enqueue();
 
@@ -155,3 +167,21 @@ void FIFO::Dequeue(ms_packet *p)
 }
 /*----------------------------------------------------------------------------------------------*/
 
+
+/*----------------------------------------------------------------------------------------------*/
+void FIFO::ResetSource()
+{
+
+	if(pSource != NULL)
+	{
+		delete pSource;
+		pSource = new GPS_Source(&amp;gopt);
+	}
+	else
+	{
+		pSource = new GPS_Source(&amp;gopt);
+	}
+
+}
+/*----------------------------------------------------------------------------------------------*/
+</diff>
      <filename>objects/fifo.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e1a696e7592910d3d2b0861bbed3e7077baa10c6</id>
    </parent>
  </parents>
  <author>
    <name>gpssim</name>
    <email>gpssim@gpsdevc.(none)</email>
  </author>
  <url>http://github.com/gps-sdr/gps-sdr/commit/271efd1d467ca8b7ce49934b3c23633af33a41ce</url>
  <id>271efd1d467ca8b7ce49934b3c23633af33a41ce</id>
  <committed-date>2009-09-14T10:39:26-07:00</committed-date>
  <authored-date>2009-09-14T10:39:26-07:00</authored-date>
  <message>Added watchdog to monitor USRP/GN3S. Attempts to restart USRP/GN3S driver if no reads have occured for 1 second.</message>
  <tree>e59905f303f3d6414b4866abf36b76e355fce7b7</tree>
  <committer>
    <name>gpssim</name>
    <email>gpssim@gpsdevc.(none)</email>
  </committer>
</commit>
