--- gpsdrive-1.28.orig/src/gpsd.c	Thu Sep 19 10:33:36 2002
+++ gpsdrive-1.28/src/gpsd.c	Tue Sep 24 22:27:26 2002
@@ -103,6 +103,7 @@
 
 #define QLEN		5
 #define BUFSIZE		4096
+#define GPS_TIMEOUT	5	/* Consider GPS connection loss after 5 sec */
 
 int debug = 0;
 int device_speed = B4800;
@@ -219,6 +220,7 @@
   double baud;
   char buf[BUFSIZE];
   int sentdgps = 0, fixcnt = 0;
+  time_t curtime;
 
   while ((option = getopt (argc, argv, "D:L:S:T:hncl:p:s:d:r:F:f:")) != -1)
     {
@@ -443,6 +445,11 @@
 	    continue;
 	  errexit ("select");
 	}
+      curtime = time(NULL);
+      if (curtime > gNMEAdata.last_update + GPS_TIMEOUT) {
+        gNMEAdata.mode = 0;
+        gNMEAdata.status = 0;
+      }
       if (FD_ISSET (dsock, &rfds))
 	{
 	  int rtcmbytes, cnt;
diff -u -r -d gpsdrive-1.28.orig/src/nmea.h gpsdrive-1.28/src/nmea.h
--- gpsdrive-1.28.orig/src/nmea.h	Fri Apr  5 22:07:38 2002
+++ gpsdrive-1.28/src/nmea.h	Tue Sep 24 22:30:26 2002
@@ -1,3 +1,4 @@
+#include <time.h>
 
 #define GPGGA "GPGGA"
 #define GPGSA "GPGSA"
@@ -9,6 +10,8 @@
     int fdin;
     int fdout;
 
+    time_t last_update;		/* When we got last data from GPS receiver */
+
     long cmask;
     char utc[20];		/* UTC date / time in format "mm/dd/yy hh:mm:ss" */
 
diff -u -r -d gpsdrive-1.28.orig/src/nmea_parse.c gpsdrive-1.28/src/nmea_parse.c
--- gpsdrive-1.28.orig/src/nmea_parse.c	Fri Apr  5 22:07:38 2002
+++ gpsdrive-1.28/src/nmea_parse.c	Tue Sep 24 22:29:46 2002
@@ -141,7 +141,7 @@
 {
     double lat, lon, d, m;
     char str[20], *p;
-
+    int updated = 0;
 
     if (*(p = field(sentence, begin + 0)) != '\0') {
 	strncpy(str, p, 20);
@@ -155,6 +155,7 @@
 	    gNMEAdata.latitude = lat;
 	    gNMEAdata.cmask |= C_LATLON;
 	}
+        updated++;
     }
     if (*(p = field(sentence, begin + 2)) != '\0') {
 	strncpy(str, p, 20);
@@ -169,7 +170,10 @@
 	    gNMEAdata.longitude = lon;
 	    gNMEAdata.cmask |= C_LATLON;
 	}
+        updated++;
     }
+    if (updated == 2)
+        gNMEAdata.last_update = time(NULL);
 }
 
 
