summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2004-09-29 18:07:47 +0000
committerEric S. Raymond <esr@thyrsus.com>2004-09-29 18:07:47 +0000
commitba2483268f2142145f5b7cf8178b7082a137a7c8 (patch)
treeb4b271575baf0064c9ba1231499cd038e81d3ec6
parentb6086d503de79d75571bb5c39297584fc84598e4 (diff)
downloadgpsd-ba2483268f2142145f5b7cf8178b7082a137a7c8.tar.gz
Remove some redundant structure members.
-rw-r--r--display.c1
-rw-r--r--drivers.c13
-rw-r--r--gps.c3
-rw-r--r--gpsd.c1
-rw-r--r--netlib.c1
-rw-r--r--serial.c11
-rw-r--r--zodiac.c12
7 files changed, 16 insertions, 26 deletions
diff --git a/display.c b/display.c
index 752e24a4..955b4474 100644
--- a/display.c
+++ b/display.c
@@ -1,6 +1,5 @@
#include "config.h"
-#include <stdio.h>
#include <Xm/Xm.h>
#include <math.h>
diff --git a/drivers.c b/drivers.c
index 25a17318..289582b6 100644
--- a/drivers.c
+++ b/drivers.c
@@ -2,11 +2,8 @@
* Drivers for generic NMEA device, TripMate and Zodiac EarthMate in text mode.
*/
#include "config.h"
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <time.h>
-#include <fcntl.h>
#include <string.h>
#include "gps.h"
@@ -126,7 +123,7 @@ struct gps_type_t nmea =
void fv18_initializer(struct gps_session_t *session)
{
/* tell it to send GSAs so we'll know if 3D is accurate */
- nmea_send(session->fdout, "$PFEC,GPint,GSA01,DTM00,ZDA00,RMC01,GLL01");
+ nmea_send(session->gpsd_fd, "$PFEC,GPint,GSA01,DTM00,ZDA00,RMC01,GLL01");
}
struct gps_type_t fv18 =
@@ -171,9 +168,9 @@ static void tripmate_initializer(struct gps_session_t *session)
struct tm *tm;
/* TripMate requires this response to the ASTRAL it sends at boot time */
- nmea_send(session->fdout, "$IIGPQ,ASTRAL");
+ nmea_send(session->gpsd_fd, "$IIGPQ,ASTRAL");
/* stop it sending PRWIZCH */
- nmea_send(session->fdout, "$PRWIILOG,ZCH,V,,");
+ nmea_send(session->gpsd_fd, "$PRWIILOG,ZCH,V,,");
if (session->initpos.latitude && session->initpos.longitude) {
t = time(NULL);
tm = gmtime(&t);
@@ -181,7 +178,7 @@ static void tripmate_initializer(struct gps_session_t *session)
if(tm->tm_year > 100)
tm->tm_year = tm->tm_year - 100;
- nmea_send(session->fdout,
+ nmea_send(session->gpsd_fd,
"$PRWIINIT,V,,,%s,%c,%s,%c,100.0,0.0,M,0.0,T,%02d%02d%02d,%02d%02d%02d",
session->initpos.latitude, session->initpos.latd,
session->initpos.longitude, session->initpos.lond,
@@ -233,7 +230,7 @@ static void earthmate_close(struct gps_session_t *session)
static void earthmate_initializer(struct gps_session_t *session)
{
- write(session->fdout, "EARTHA\r\n", 8);
+ write(session->gpsd_fd, "EARTHA\r\n", 8);
sleep(30);
session->device_type = &zodiac_binary;
zodiac_binary.wrapup = earthmate_close;
diff --git a/gps.c b/gps.c
index 49e5fa30..8fe1ddd4 100644
--- a/gps.c
+++ b/gps.c
@@ -1,13 +1,10 @@
/* include files */
#include "config.h"
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
#include <errno.h>
#include <signal.h>
diff --git a/gpsd.c b/gpsd.c
index b5b99c9d..e19ac078 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -4,6 +4,7 @@
#include <syslog.h>
#include <signal.h>
#include <errno.h>
+#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include <netdb.h>
diff --git a/netlib.c b/netlib.c
index 499b0f71..19a21305 100644
--- a/netlib.c
+++ b/netlib.c
@@ -10,7 +10,6 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
-#include <stdio.h>
#include <arpa/inet.h>
#include "config.h"
diff --git a/serial.c b/serial.c
index 57e129a5..906ace5b 100644
--- a/serial.c
+++ b/serial.c
@@ -44,8 +44,7 @@ int gpsd_open(char *device_name, int device_speed, int stopbits)
int ttyfd;
gpsd_report(1, "opening GPS data source at %s\n", device_name);
- ttyfd = open(device_name, O_RDWR | O_NONBLOCK);
- if (ttyfd < 0)
+ if ((ttyfd = open(device_name, O_RDWR | O_NONBLOCK)) < 0)
return -1;
if (isatty(ttyfd)) {
@@ -71,6 +70,7 @@ int gpsd_open(char *device_name, int device_speed, int stopbits)
}
void gpsd_close(int ttyfd)
+/* restore original terminal settings, but make sure DTR goes down */
{
if (ttyfd != -1) {
if (isatty(ttyfd)) {
@@ -81,12 +81,9 @@ void gpsd_close(int ttyfd)
ttyset.c_ospeed = B0;
#endif
tcsetattr(ttyfd, TCSANOW, &ttyset);
+ ttyset_old.c_cflag |= HUPCL;
+ tcsetattr(ttyfd,TCSANOW,&ttyset_old);
}
- /* Restore original terminal parameters */
- /* but make sure DTR goes down */
- ttyset_old.c_cflag |= HUPCL;
- tcsetattr(ttyfd,TCSANOW,&ttyset_old);
-
close(ttyfd);
}
}
diff --git a/zodiac.c b/zodiac.c
index d0fb4a52..fe71ca8c 100644
--- a/zodiac.c
+++ b/zodiac.c
@@ -92,9 +92,9 @@ static void zodiac_spew(struct gps_session_t *session, int type, unsigned short
h.ndata = dlen - 1;
h.csum = zodiac_checksum((unsigned short *) &h, 4);
- if (session->fdout != -1) {
- end_write(session->fdout, &h, sizeof(h));
- end_write(session->fdout, dat, sizeof(unsigned short) * dlen);
+ if (session->gpsd_fd != -1) {
+ end_write(session->gpsd_fd, &h, sizeof(h));
+ end_write(session->gpsd_fd, dat, sizeof(unsigned short) * dlen);
}
}
@@ -497,8 +497,8 @@ static void zodiac_eat(struct gps_session_t *session, unsigned char c)
case ZODIAC_HUNT_A:
/* A better be right after E */
- if ((c == 'A') && (session->fdout != -1))
- write(session->fdout, "EARTHA\r\n", 8);
+ if ((c == 'A') && (session->gpsd_fd != -1))
+ write(session->gpsd_fd, "EARTHA\r\n", 8);
state = ZODIAC_HUNT_FF;
break;
@@ -552,7 +552,7 @@ static int zodiac_handle_input(struct gps_session_t *session)
{
unsigned char c;
- if (read(session->fdin, &c, 1) != 1)
+ if (read(session->gpsd_fd, &c, 1) != 1)
return 1;
zodiac_eat(session, c);
return 0;