summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.splintrc8
-rw-r--r--garmin.c3
-rw-r--r--gps.h1
-rw-r--r--gpsd.c130
-rw-r--r--gpsutils.c28
-rw-r--r--libgps.c6
-rw-r--r--libgpsd_core.c25
-rw-r--r--nmea_parse.c18
-rw-r--r--packet.c57
-rw-r--r--sirf.c162
-rw-r--r--sirfmon.c280
-rw-r--r--tsip.c105
-rw-r--r--zodiac.c228
13 files changed, 541 insertions, 510 deletions
diff --git a/.splintrc b/.splintrc
index c1e953c0..50830802 100644
--- a/.splintrc
+++ b/.splintrc
@@ -1,5 +1,5 @@
-I.
-+posixlib
++unixlib
+charindex
+charintliteral
-realcompare
@@ -8,10 +8,8 @@
-paramuse
-predboolint
-nestedextern
+-abstract
--Dfd_set=int
--Dpthread_t=int
--Dsocklen_t=ssize_t
-Din_addr_t=int
-Du_int16_t=short
-Du_int8_t=short
@@ -20,7 +18,5 @@
-DCBAUDEX=0010000
-DB57600=010001
-DB115200=0010011
--Dusleep=sleep
--DEWOULDBLOCK=EAGAIN
-DCRTSCTS=0x00020000
-DONLCR=0x00000002
diff --git a/garmin.c b/garmin.c
index d0d6e7fe..12649d4e 100644
--- a/garmin.c
+++ b/garmin.c
@@ -569,11 +569,12 @@ static int GetPacket (struct gps_device_t *session )
break;
}
+ /*@ ignore @*/
delay.tv_sec = 0;
delay.tv_nsec = 3330000L;
while (nanosleep(&delay, &rem) < 0)
continue;
-
+ /*@ end @*/
}
// dump the individual bytes, debug only
// for ( x = 0; x < session->GarminBufferLen; x++ ) {
diff --git a/gps.h b/gps.h
index 035bd2df..c464e863 100644
--- a/gps.h
+++ b/gps.h
@@ -121,6 +121,7 @@ struct gps_data_t {
int satellites_used; /* Number of satellites used in solution */
int used[MAXCHANNELS]; /* PRNs of satellites used in solution */
double pdop, hdop, vdop, tdop, gdop; /* Dilution of precision */
+#define DOP_NOT_VALID 0.0
/* redundant with the estimate elments in the fix structure */
double epe; /* estimated spherical position error, 1 sigma (meters) */
diff --git a/gpsd.c b/gpsd.c
index f40fe92b..5fe4747f 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -54,7 +54,8 @@
#define PROTO_TTY "/dev/ttyS0"
static fd_set all_fds;
-static int debuglevel, in_background = 0;
+static int debuglevel;
+static bool in_background = false;
static jmp_buf restartbuf;
/*@ -initallelements @*/
static struct gps_context_t context = {0, LEAP_SECONDS, CENTURY_BASE,
@@ -90,6 +91,7 @@ static int daemonize(void)
if (setsid() == -1)
return -1;
(void)chdir("/");
+ /*@ -nullpass @*/
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
@@ -97,7 +99,8 @@ static int daemonize(void)
if (fd > 2)
(void)close(fd);
}
- in_background = 1;
+ /*@ +nullpass @*/
+ in_background = true;
return 0;
}
@@ -121,7 +124,7 @@ void gpsd_report(int errlevel, const char *fmt, ... )
va_end(ap);
/*@ -unrecog @*/
- if (in_background!=0)
+ if (in_background)
syslog((errlevel == 0) ? LOG_ERR : LOG_NOTICE, "%s", buf);
else
(void)fputs(buf, stderr);
@@ -176,20 +179,21 @@ static int passivesock(char *service, char *protocol, int qlen)
int s, type, one = 1;
memset((char *) &sin, 0, sizeof(sin));
- /*@ -unrecog @*/
- sin.sin_family = AF_INET;
+ /*@i1@*/sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
if ((pse = getservbyname(service, protocol)))
- sin.sin_port = htons(ntohs((unsigned short) /*@i1@*/pse->s_port));
- else if ((sin.sin_port = htons((unsigned short) atoi(service))) == 0) {
+ sin.sin_port = htons(ntohs((in_port_t)pse->s_port));
+ else if ((sin.sin_port = htons((in_port_t)atoi(service))) == 0) {
gpsd_report(0, "Can't get \"%s\" service entry.\n", service);
return -1;
}
+ /*@ -unrecog @*/
if ((ppe = getprotobyname(protocol)) == 0) {
gpsd_report(0, "Can't get \"%s\" protocol entry.\n", protocol);
return -1;
}
+ /*@ +unrecog @*/
if (strcmp(protocol, "udp") == 0)
type = SOCK_DGRAM;
else
@@ -198,11 +202,11 @@ static int passivesock(char *service, char *protocol, int qlen)
gpsd_report(0, "Can't create socket\n");
return -1;
}
- if (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(one)) == -1) {
+ if (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&one,(int)sizeof(one)) == -1) {
gpsd_report(0, "Error: SETSOCKOPT SO_REUSEADDR\n");
return -1;
}
- if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
+ if (bind(s, (struct sockaddr *) &sin, (int)sizeof(sin)) < 0) {
gpsd_report(0, "Can't bind to port %s\n", service);
return -1;
}
@@ -210,7 +214,6 @@ static int passivesock(char *service, char *protocol, int qlen)
gpsd_report(0, "Can't listen on %s port%s\n", service);
return -1;
}
- /*@ +unrecog @*/
return s;
}
@@ -219,20 +222,20 @@ static int filesock(char *filename)
struct sockaddr_un addr;
int s;
- /*@ -unrecog @*/
+ /*@ -mayaliasunique @*/
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
gpsd_report(0, "Can't create device-control socket\n");
return -1;
}
(void)strcpy(addr.sun_path, filename);
- addr.sun_family = AF_UNIX;
- bind(s, (struct sockaddr *) &addr, strlen(addr.sun_path) +
- sizeof (addr.sun_family));
+ /*@i1@*/addr.sun_family = AF_UNIX;
+ (void)bind(s, (struct sockaddr *) &addr,
+ (int)(strlen(addr.sun_path) + sizeof (addr.sun_family)));
if (listen(s, QLEN) < 0) {
gpsd_report(0, "Can't listen on local socket %s\n", filename);
return -1;
}
- /*@ -unrecog @*/
+ /*@ +mayaliasunique @*/
return s;
}
@@ -247,9 +250,9 @@ static int filesock(char *filename)
static struct gps_device_t *channels[MAXDEVICES];
static struct subscriber_t {
- int active; /* is this a subscriber? */
- int tied; /* client set device with F */
- int watcher; /* is client in watcher mode? */
+ bool active; /* is this a subscriber? */
+ bool tied; /* client set device with F */
+ bool watcher; /* is client in watcher mode? */
int raw; /* is client in raw mode? */
/*@relnull@*/struct gps_device_t *device; /* device subscriber listens to */
} subscribers[FD_SETSIZE]; /* indexed by client file descriptor */
@@ -259,8 +262,8 @@ static void detach_client(int cfd)
(void)close(cfd);
/*@i@*/ FD_CLR(cfd, &all_fds);
subscribers[cfd].raw = 0;
- subscribers[cfd].watcher = 0;
- subscribers[cfd].active = 0;
+ subscribers[cfd].watcher = false;
+ subscribers[cfd].active = false;
subscribers[cfd].device = NULL;
}
@@ -364,14 +367,14 @@ static char *snarfline(char *p, /*@out@*/char **out)
char *q;
static char stash[BUFSIZ];
- /*@ -temptrans @*/
+ /*@ -temptrans -mayaliasunique @*/
for (q = p; isprint(*p) && !isspace(*p) && /*@i@*/(p-q < BUFSIZ-1); p++)
continue;
(void)memcpy(stash, q, (size_t)(p-q));
stash[p-q] = '\0';
*out = stash;
return p;
- /*@ +temptrans @*/
+ /*@ +temptrans +mayaliasunique @*/
}
static bool assign_channel(struct subscriber_t *user)
@@ -401,7 +404,7 @@ static bool assign_channel(struct subscriber_t *user)
return false;
else {
/*@i@*/FD_SET(user->device->gpsdata.gps_fd, &all_fds);
- if (user->watcher!=0 && user->tied==0) {
+ if (user->watcher && !user->tied) {
(void)write(user-subscribers, "F=", 2);
(void)write(user-subscribers,
user->device->gpsdata.gps_device,
@@ -442,7 +445,7 @@ static int handle_request(int cfd, char *buf, int buflen)
i = atoi(++p);
while (isdigit(*p)) p++;
if (whoami->device->device_type->speed_switcher)
- if (whoami->device->device_type->speed_switcher(whoami->device, i)) {
+ if (whoami->device->device_type->speed_switcher(whoami->device, (unsigned)i)) {
/*
* Allow the control string time to register at the
* GPS before we do the baud rate switch, which
@@ -491,13 +494,15 @@ static int handle_request(int cfd, char *buf, int buflen)
break;
case 'E':
if (assign_channel(whoami) && have_fix(whoami->device)) {
- if (whoami->device->gpsdata.fix.eph
- || whoami->device->gpsdata.fix.epv)
+ if (whoami->device->gpsdata.fix.eph != UNCERTAINTY_NOT_VALID
+ || whoami->device->gpsdata.fix.epv != UNCERTAINTY_NOT_VALID)
(void)snprintf(phrase, sizeof(phrase), ",E=%.2f %.2f %.2f",
whoami->device->gpsdata.epe,
whoami->device->gpsdata.fix.eph,
whoami->device->gpsdata.fix.epv);
- else if (whoami->device->gpsdata.pdop || whoami->device->gpsdata.hdop || whoami->device->gpsdata.vdop)
+ else if (whoami->device->gpsdata.pdop != DOP_NOT_VALID
+ || whoami->device->gpsdata.hdop != DOP_NOT_VALID
+ || whoami->device->gpsdata.vdop!= DOP_NOT_VALID)
(void)snprintf(phrase, sizeof(phrase), ",E=%.2f %.2f %.2f",
whoami->device->gpsdata.pdop * UERE(whoami->device),
whoami->device->gpsdata.hdop * UERE(whoami->device),
@@ -511,7 +516,7 @@ static int handle_request(int cfd, char *buf, int buflen)
gpsd_report(1,"<= client(%d): switching to %s\n",cfd,stash);
if ((newchan = find_device(stash))) {
whoami->device = *newchan;
- whoami->tied = 1;
+ whoami->tied = true;
}
free(stash);
}
@@ -585,13 +590,13 @@ static int handle_request(int cfd, char *buf, int buflen)
whoami->device->gpsdata.fix.altitude);
else
(void)strcat(phrase, " ?");
- if (whoami->device->gpsdata.fix.eph)
+ if (whoami->device->gpsdata.fix.eph != UNCERTAINTY_NOT_VALID)
(void)snprintf(phrase+strlen(phrase),
sizeof(phrase)-strlen(phrase),
" %5.2f", whoami->device->gpsdata.fix.eph);
else
(void)strcat(phrase, " ?");
- if (whoami->device->gpsdata.fix.epv)
+ if (whoami->device->gpsdata.fix.epv != UNCERTAINTY_NOT_VALID)
(void)snprintf(phrase+strlen(phrase),
sizeof(phrase)-strlen(phrase),
" %5.2f", whoami->device->gpsdata.fix.epv);
@@ -636,7 +641,10 @@ static int handle_request(int cfd, char *buf, int buflen)
(void)strcpy(phrase, ",P=?");
break;
case 'Q':
- if (assign_channel(whoami) && (whoami->device->gpsdata.pdop || whoami->device->gpsdata.hdop || whoami->device->gpsdata.vdop))
+ if (assign_channel(whoami) &&
+ (whoami->device->gpsdata.pdop != UNCERTAINTY_NOT_VALID
+ || whoami->device->gpsdata.hdop != UNCERTAINTY_NOT_VALID
+ || whoami->device->gpsdata.vdop != UNCERTAINTY_NOT_VALID))
(void)snprintf(phrase, sizeof(phrase), ",Q=%d %.2f %.2f %.2f %.2f %.2f",
whoami->device->gpsdata.satellites_used,
whoami->device->gpsdata.pdop,
@@ -704,12 +712,12 @@ static int handle_request(int cfd, char *buf, int buflen)
case 'W':
if (*p == '=') ++p;
if (*p == '1' || *p == '+') {
- subscribers[cfd].watcher = 1;
+ subscribers[cfd].watcher = true;
(void)assign_channel(whoami);
(void)snprintf(phrase, sizeof(phrase), ",W=1");
p++;
} else if (*p == '0' || *p == '-') {
- subscribers[cfd].watcher = 0;
+ subscribers[cfd].watcher = false;
(void)snprintf(phrase, sizeof(phrase), ",W=0");
p++;
} else if (subscribers[cfd].watcher!=0) {
@@ -897,7 +905,7 @@ int main(int argc, char *argv[])
struct passwd *pw;
struct stat stb;
struct timeval tv;
- extern char *optarg;
+ // extern char *optarg;
debuglevel = 0;
while ((option = getopt(argc, argv, "F:D:S:d:fhNnpP:v")) != -1) {
@@ -1073,6 +1081,7 @@ int main(int argc, char *argv[])
* actually matter here since select returns whenever one of
* the file descriptors in the set goes ready.
*/
+ /*@ -usedef @*/
tv.tv_sec = 1; tv.tv_usec = 0;
if (select(FD_SETSIZE, &rfds, NULL, NULL, &tv) < 0) {
if (errno == EINTR)
@@ -1080,6 +1089,7 @@ int main(int argc, char *argv[])
gpsd_report(0, "select: %s\n", strerror(errno));
exit(2);
}
+ /*@ +usedef @*/
#ifdef __UNUSED__
{
@@ -1096,8 +1106,8 @@ int main(int argc, char *argv[])
/* always be open to new client connections */
if (/*@i@*/FD_ISSET(msock, &rfds)) {
- socklen_t alen = sizeof(fsin);
- int ssock = accept(msock, (struct sockaddr *) &fsin, &alen);
+ socklen_t alen = (socklen_t)sizeof(fsin);
+ /*@i1@*/int ssock = accept(msock, (struct sockaddr *) &fsin, &alen);
if (ssock < 0)
gpsd_report(0, "accept: %s\n", strerror(errno));
@@ -1108,16 +1118,16 @@ int main(int argc, char *argv[])
(void)fcntl(ssock, F_SETFL, opts | O_NONBLOCK);
gpsd_report(3, "client connect on %d\n", ssock);
/*@i@*/FD_SET(ssock, &all_fds);
- subscribers[ssock].active = 1;
- subscribers[ssock].tied = 0;
+ subscribers[ssock].active = true;
+ subscribers[ssock].tied = false;
}
/*@i@*/FD_CLR(msock, &rfds);
}
/* also be open to new control-socket connections */
if (csock > -1 && /*@i@*/FD_ISSET(csock, &rfds)) {
- socklen_t alen = sizeof(fsin);
- int ssock = accept(csock, (struct sockaddr *) &fsin, &alen);
+ socklen_t alen = (socklen_t)sizeof(fsin);
+ /*@i1@*/int ssock = accept(csock, (struct sockaddr *) &fsin, &alen);
if (ssock < 0)
gpsd_report(0, "accept: %s\n", strerror(errno));
@@ -1149,33 +1159,33 @@ int main(int argc, char *argv[])
/* poll all active devices */
for (channel = channels; channel < channels + MAXDEVICES; channel++) {
- struct gps_device_t *device = *channel;
+ struct gps_device_t *polldevice = *channel;
- if (!device)
+ if (!polldevice)
continue;
/* we may need to force the GPS open */
- if (nowait && device->gpsdata.gps_fd == -1) {
- gpsd_deactivate(device);
- if (gpsd_activate(device) >= 0) {
- /*@i@*/FD_SET(device->gpsdata.gps_fd, &all_fds);
- notify_watchers(device, "GPSD,X=%f\r\n", timestamp());
+ if (nowait && polldevice->gpsdata.gps_fd == -1) {
+ gpsd_deactivate(polldevice);
+ if (gpsd_activate(polldevice) >= 0) {
+ /*@i@*/FD_SET(polldevice->gpsdata.gps_fd, &all_fds);
+ notify_watchers(polldevice, "GPSD,X=%f\r\n", timestamp());
}
}
/* get data from the device */
changed = 0;
- if (device->gpsdata.gps_fd >= 0)
+ if (polldevice->gpsdata.gps_fd >= 0)
{
- changed = gpsd_poll(device);
+ changed = gpsd_poll(polldevice);
if (changed == ERROR_SET) {
gpsd_report(3, "packet sniffer failed to sync up\n");
- /*@i@*/FD_CLR(device->gpsdata.gps_fd, &all_fds);
- gpsd_deactivate(device);
- } if (!(changed & ONLINE_SET)) {
+ /*@i@*/FD_CLR(polldevice->gpsdata.gps_fd, &all_fds);
+ gpsd_deactivate(polldevice);
+ } if ((changed & ONLINE_SET) == 0) {
gpsd_report(3, "GPS is offline\n");
- /*@i@*/FD_CLR(device->gpsdata.gps_fd, &all_fds);
- gpsd_deactivate(device);
- notify_watchers(device, "GPSD,X=0\r\n");
+ /*@i@*/FD_CLR(polldevice->gpsdata.gps_fd, &all_fds);
+ gpsd_deactivate(polldevice);
+ notify_watchers(polldevice, "GPSD,X=0\r\n");
}
}
@@ -1183,17 +1193,17 @@ int main(int argc, char *argv[])
/* some listeners may be in watcher mode */
if (subscribers[cfd].watcher) {
char cmds[4] = "";
- device->poll_times[cfd] = timestamp();
+ polldevice->poll_times[cfd] = timestamp();
if (changed &~ ONLINE_SET) {
if (changed & (LATLON_SET | MODE_SET))
(void)strcat(cmds, "o");
if (changed & SATELLITE_SET)
(void)strcat(cmds, "y");
}
- if (device->gpsdata.profiling && device->packet_full)
+ if (polldevice->gpsdata.profiling!=0 && polldevice->packet_full!=0)
(void)strcat(cmds, "$");
- if (cmds[0])
- (void)handle_request(cfd, cmds, strlen(cmds));
+ if (cmds[0] != '\0')
+ (void)handle_request(cfd, cmds, (int)strlen(cmds));
}
}
#if DBUS_ENABLE
@@ -1211,7 +1221,7 @@ int main(int argc, char *argv[])
int buflen;
gpsd_report(3, "checking %d\n", cfd);
- if ((buflen = read(cfd, buf, sizeof(buf) - 1)) <= 0) {
+ if ((buflen = (int)read(cfd, buf, sizeof(buf) - 1)) <= 0) {
detach_client(cfd);
} else {
buf[buflen] = '\0';
diff --git a/gpsutils.c b/gpsutils.c
index 841a23fb..69d53da3 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -14,17 +14,18 @@ double timestamp(void)
{
struct timeval tv;
(void)gettimeofday(&tv, NULL);
- return(tv.tv_sec + tv.tv_usec/1e6);
+ /*@i1@*/return(tv.tv_sec + tv.tv_usec*1e-6);
}
time_t mkgmtime(register struct tm *t)
/* struct tm to seconds since Unix epoch */
{
- register unsigned short year;
+ register int year;
register time_t result;
static const int cumdays[12] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+ /*@ +matchanyintegral @*/
year = 1900 + t->tm_year + t->tm_mon / 12;
result = (year - 1970) * 365 + cumdays[t->tm_mon % 12];
result += (year - 1968) / 4;
@@ -37,6 +38,7 @@ time_t mkgmtime(register struct tm *t)
result += t->tm_min;
result *= 60;
result += t->tm_sec;
+ /*@ -matchanyintegral @*/
return (result);
}
@@ -47,12 +49,15 @@ double iso8601_to_unix(char *isotime)
double usec;
struct tm tm;
+ /*@ -unrecog -compdef @*//* splint 3.1.1 doesn't grok strptime */
dp = strptime(isotime, "%Y-%m-%dT%H:%M:%S", &tm);
+ /*@ +unrecog @*/
if (*dp == '.')
usec = strtod(dp, NULL);
else
usec = 0;
- return mkgmtime(&tm) + usec;
+ return (double)mkgmtime(&tm) + usec;
+ /*@ +compdef @*/
}
char *unix_to_iso8601(double fixtime, char isotime[], int len)
@@ -61,15 +66,18 @@ char *unix_to_iso8601(double fixtime, char isotime[], int len)
struct tm when;
double integral, fractional;
time_t intfixtime;
- int slen;
+ size_t slen;
fractional = modf(fixtime, &integral);
intfixtime = (time_t)integral;
+ /*@ -unrecog -compdef */
(void)gmtime_r(&intfixtime, &when);
+ /*@ -unrecog */
(void)strftime(isotime, 28, "%Y-%m-%dT%H:%M:%S", &when);
+ /*@ -unrecog -compdef */
slen = strlen(isotime);
- (void)snprintf(isotime + slen, len, "%.1f", fractional);
+ (void)snprintf(isotime + slen, (size_t)len, "%.1f", fractional);
(void)memcpy(isotime+slen, isotime+slen+1, strlen(isotime+slen+1));
(void)strcat(isotime, "Z");
return isotime;
@@ -103,7 +111,7 @@ double gpstime_to_unix(int week, double tow)
time_t now, last_rollover;
(void)time(&now);
last_rollover = GPS_EPOCH+((now-GPS_EPOCH)/GPS_ROLLOVER)*GPS_ROLLOVER;
- fixtime = last_rollover + (week * SECS_PER_WEEK) + tow;
+ /*@i@*/fixtime = last_rollover + (week * SECS_PER_WEEK) + tow;
}
return fixtime;
}
@@ -247,6 +255,7 @@ driver.
******************************************************************************/
+/*@ -fixedformalarray @*/
static int invert(double mat[4][4], double inverse[4][4])
{
// Find all NECESSARY 2x2 subdeterminants
@@ -336,6 +345,7 @@ static int invert(double mat[4][4], double inverse[4][4])
return 1;
}
+/*@ +fixedformalarray @*/
void dop(int channels, struct gps_data_t *gpsdata)
{
@@ -354,7 +364,7 @@ void dop(int channels, struct gps_data_t *gpsdata)
#endif /* __UNUSED__ */
for (n = k = 0; k < channels; k++) {
- if (!gpsdata->used[k])
+ if (gpsdata->used[k] != 0)
continue;
satpos[n][0] = sin(gpsdata->azimuth[k]*DEG_2_RAD)
* cos(gpsdata->elevation[k]*DEG_2_RAD);
@@ -402,12 +412,14 @@ void dop(int channels, struct gps_data_t *gpsdata)
} else
gpsd_report(0, "Matrix is singular.\n");
#else
- invert(prod, inv);
+ (void)invert(prod, inv);
#endif /* __UNUSED__ */
+ /*@ -usedef @*/
//gpsdata->hdop = sqrt(inv[0][0] + inv[1][1]);
gpsdata->vdop = sqrt(inv[1][1]);
gpsdata->pdop = sqrt(inv[0][0] + inv[1][1] + inv[2][2]);
gpsdata->tdop = sqrt(inv[3][3]);
gpsdata->gdop = sqrt(inv[0][0] + inv[1][1] + inv[2][2] + inv[3][3]);
+ /*@ +usedef @*/
}
diff --git a/libgps.c b/libgps.c
index d021d9ce..943a4486 100644
--- a/libgps.c
+++ b/libgps.c
@@ -144,7 +144,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
int i;
for (ns = buf; ns; ns = strstr(ns+1, "GPSD")) {
- if (!strncmp(ns, "GPSD", 4)) {
+ if (strncmp(ns, "GPSD", 4) == 0) {
for (sp = ns + 5; ; sp = tp) {
tp = sp + strcspn(sp, ",\r\n");
if (!*tp) break;
@@ -163,7 +163,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?') {
gpsdata->baudrate = gpsdata->stopbits = 0;
} else
- (void)sscanf(sp, "B=%d %*d %*s %d",
+ (void)sscanf(sp, "B=%d %*d %*s %u",
&gpsdata->baudrate, &gpsdata->stopbits);
break;
case 'C':
@@ -241,7 +241,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
break;
case 'N':
if (sp[2] == '?')
- gpsdata->driver_mode = -1;
+ gpsdata->driver_mode = 0;
else
gpsdata->driver_mode = atoi(sp+2);
break;
diff --git a/libgpsd_core.c b/libgpsd_core.c
index fe3e338f..1bc5b436 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -36,7 +36,7 @@ int gpsd_open_dgps(char *dgpsserver)
dsock = netlib_connectsock(dgpsserver, dgpsport, "tcp");
if (dsock >= 0) {
- gethostname(hn, sizeof(hn));
+ (void)gethostname(hn, sizeof(hn));
(void)snprintf(buf,sizeof(buf), "HELO %s gpsd %s\r\nR\r\n",hn,VERSION);
(void)write(dsock, buf, strlen(buf));
}
@@ -69,11 +69,11 @@ struct gps_device_t *gpsd_init(struct gps_context_t *context, char *device)
session->device_type = NULL; /* start by hunting packets */
session->dsock = -1;
session->context = context;
- session->gpsdata.hdop = 0.0;
- session->gpsdata.vdop = 0.0;
- session->gpsdata.pdop = 0.0;
- session->gpsdata.tdop = 0.0;
- session->gpsdata.gdop = 0.0;
+ session->gpsdata.hdop = DOP_NOT_VALID;
+ session->gpsdata.vdop = DOP_NOT_VALID;
+ session->gpsdata.pdop = DOP_NOT_VALID;
+ session->gpsdata.tdop = DOP_NOT_VALID;
+ session->gpsdata.gdop = DOP_NOT_VALID;
/* mark GPS fd closed */
session->gpsdata.gps_fd = -1;
@@ -106,8 +106,7 @@ void gpsd_deactivate(struct gps_device_t *session)
static void *gpsd_ppsmonitor(void *arg)
{
struct gps_device_t *session = (struct gps_device_t *)arg;
- int cycle,duration;
- bool state;
+ int cycle,duration, state;
struct timeval tv;
struct timeval pulse[2] = {{0,0},{0,0}};
@@ -134,10 +133,10 @@ static void *gpsd_ppsmonitor(void *arg)
*/
#define timediff(x, y) ((x.tv_sec-y.tv_sec)*1000000+x.tv_usec-y.tv_usec)
cycle = timediff(tv, pulse[state]);
- duration = timediff(tv, pulse[!state]);
+ duration = timediff(tv, pulse[state == 0]);
#undef timediff
if (cycle > 999000 && cycle < 1001000 && duration > 800000)
- ntpshm_pps(session, &tv);
+ (void)ntpshm_pps(session, &tv);
}
pulse[state] = tv;
@@ -194,7 +193,7 @@ static int is_input_waiting(int fd)
return count;
}
-static int handle_packet(struct gps_device_t *session)
+static long handle_packet(struct gps_device_t *session)
{
session->packet_full = 0;
session->gpsdata.sentence_time = 0;
@@ -273,7 +272,7 @@ static int handle_packet(struct gps_device_t *session)
session->gpsdata.d_decode_time = timestamp();
/* may be time to ship a DGPS correction to the GPS */
- if (session->fixcnt > 10 && !session->sentdgps) {
+ if (session->fixcnt > 10 && session->sentdgps==0) {
session->sentdgps++;
if (session->dsock > -1) {
char buf[BUFSIZ];
@@ -414,7 +413,7 @@ void gpsd_binary_fix_dump(struct gps_device_t *session, char bufp[], int len)
if (session->gpsdata.hdop)
(void)snprintf(hdop_str,sizeof(hdop_str),"%.2f",session->gpsdata.hdop);
- intfixtime = (int)session->gpsdata.fix.time;
+ intfixtime = (time_t)session->gpsdata.fix.time;
gmtime_r(&intfixtime, &tm);
if (session->gpsdata.fix.mode > 1) {
(void)snprintf(bufp, len,
diff --git a/nmea_parse.c b/nmea_parse.c
index d297b7a5..36af3310 100644
--- a/nmea_parse.c
+++ b/nmea_parse.c
@@ -65,7 +65,7 @@ static void do_lat_lon(char *field[], struct gps_data_t *out)
*
**************************************************************************/
-#define DD(s) ((s)[0]-'0')*10+((s)[1]-'0')
+#define DD(s) ((int)((s)[0]-'0')*10+(int)((s)[1]-'0'))
static void merge_ddmmyy(char *ddmmyy, struct gps_data_t *out)
/* sentence supplied ddmmyy, but no century part */
@@ -510,18 +510,19 @@ int nmea_parse(char *sentence, struct gps_data_t *outdata)
}
#endif /* __ UNUSED__ */
+ /*@ -usedef @*//* splint 3.1.1 seems to have a bug here */
/* make an editable copy of the sentence */
- strncpy(buf, sentence, NMEA_MAX);
+ strncpy((char *)buf, sentence, NMEA_MAX);
/* discard the checksum part */
- for (p = buf; (*p != '*') && (*p >= ' '); ) ++p;
+ for (p = (char *)buf; (*p != '*') && (*p >= ' '); ) ++p;
*p = '\0';
/* split sentence copy on commas, filling the field array */
- for (count = 0, p = buf; p != NULL && *p; ++count, p = strchr(p, ',')) {
+ for (count = 0, p = (char *)buf; p != NULL && *p != '\0'; ++count, p = strchr(p, ',')) {
*p = '\0';
field[count] = ++p;
}
/* dispatch on field zero, the sentence tag */
- for (i = 0; i < sizeof(nmea_phrase)/sizeof(nmea_phrase[0]); ++i) {
+ for (i = 0; i < (unsigned)(sizeof(nmea_phrase)/sizeof(nmea_phrase[0])); ++i) {
s = field[0];
if (strlen(nmea_phrase[i].name) == 3)
s += 2; /* skip talker ID */
@@ -536,13 +537,14 @@ int nmea_parse(char *sentence, struct gps_data_t *outdata)
break;
}
}
+ /*@ +usedef @*/
return retval;
}
int nmea_send(int fd, const char *fmt, ... )
/* ship a command to the GPS, adding * and correct checksum */
{
- unsigned int status;
+ int status;
char buf[BUFSIZ];
va_list ap;
@@ -551,8 +553,8 @@ int nmea_send(int fd, const char *fmt, ... )
va_end(ap);
strcat(buf, "*");
nmea_add_checksum(buf);
- status = write(fd, buf, strlen(buf));
- if (status == strlen(buf)) {
+ status = (int)write(fd, buf, strlen(buf));
+ if (status == (int)strlen(buf)) {
gpsd_report(2, "=> GPS: %s\n", buf);
return status;
} else {
diff --git a/packet.c b/packet.c
index 76970adf..a51d2309 100644
--- a/packet.c
+++ b/packet.c
@@ -180,9 +180,7 @@ static void nexstate(struct gps_device_t *session, unsigned char c)
else if (c == '\n')
/* not strictly correct, but helps for interpreting logfiles */
session->packet_state = NMEA_RECOGNIZED;
- else if (isprint(c))
- /* continue gathering body packets */;
- else
+ else if (!isprint(c))
session->packet_state = GROUND_STATE;
break;
case NMEA_CR:
@@ -391,18 +389,18 @@ static void nexstate(struct gps_device_t *session, unsigned char c)
break;
case ZODIAC_HSUM_1:
{
- #define getw(i) (short)(session->inbuffer[2*(i)] | (session->inbuffer[2*(i)+1] << 8))
- short sum = getw(0) + getw(1) + getw(2) + getw(3);
+ #define getword(i) (short)(session->inbuffer[2*(i)] | (session->inbuffer[2*(i)+1] << 8))
+ short sum = getword(0) + getword(1) + getword(2) + getword(3);
sum *= -1;
- if (sum != getw(4)) {
+ if (sum != getword(4)) {
gpsd_report(4, "Zodiac Header checksum 0x%hx expecting 0x%hx\n",
- sum, getw(4));
+ sum, getword(4));
session->packet_state = GROUND_STATE;
break;
}
}
- gpsd_report(6,"Zodiac header id=%hd len=%hd flags=%hx\n", getw(1), getw(2), getw(3));
- #undef getw
+ gpsd_report(6,"Zodiac header id=%hd len=%hd flags=%hx\n", getword(1), getword(2), getword(3));
+ #undef getword
if (session->packet_length == 0) {
session->packet_state = ZODIAC_RECOGNIZED;
break;
@@ -445,10 +443,11 @@ static char *buffer_dump(unsigned char *base, unsigned char *end)
static void packet_accept(struct gps_device_t *session, int packet_type)
/* packet grab succeeded, move to output buffer */
{
- unsigned int packetlen = session->inbufptr-session->inbuffer;
+ size_t packetlen = session->inbufptr-session->inbuffer;
if (packetlen < sizeof(session->outbuffer)) {
memcpy(session->outbuffer, session->inbuffer, packetlen);
- session->outbuffer[session->outbuflen = packetlen] = '\0';
+ session->outbuflen = (unsigned short)packetlen;
+ session->outbuffer[packetlen] = '\0';
session->packet_type = packet_type;
#ifdef STATE_DEBUG
gpsd_report(6, "Packet type %d accepted %d = %s\n",
@@ -465,12 +464,12 @@ static void packet_accept(struct gps_device_t *session, int packet_type)
static void packet_discard(struct gps_device_t *session)
/* shift the input buffer to discard all data up to current input pointer */
{
- int discard = session->inbufptr - session->inbuffer;
- int remaining = session->inbuflen - discard;
+ size_t discard = session->inbufptr - session->inbuffer;
+ size_t remaining = session->inbuflen - discard;
session->inbufptr = memmove(session->inbuffer,
session->inbufptr,
remaining);
- session->inbuflen = remaining;
+ session->inbuflen = (unsigned short)remaining;
#ifdef STATE_DEBUG
gpsd_report(6, "Packet discard of %d, chars remaining is %d = %s\n",
discard, remaining,
@@ -482,7 +481,7 @@ static void packet_discard(struct gps_device_t *session)
static void character_discard(struct gps_device_t *session)
/* shift the input buffer to discard one character and reread data */
{
- memmove(session->inbuffer, session->inbuffer + 1, --session->inbuflen);
+ memmove(session->inbuffer, session->inbuffer+1, (size_t)--session->inbuflen);
session->inbufptr = session->inbuffer;
#ifdef STATE_DEBUG
gpsd_report(6, "Character discarded, buffer %d chars = %s\n",
@@ -512,7 +511,7 @@ int packet_get(struct gps_device_t *session, unsigned int waiting)
session->inbufptr = session->inbuffer;
session->inbuflen = 0;
}
- newdata = read(session->gpsdata.gps_fd, session->inbufptr, waiting);
+ newdata = (int)read(session->gpsdata.gps_fd, session->inbufptr, (size_t)waiting);
#else
newdata = waiting;
#endif /* TESTMAIN */
@@ -540,12 +539,12 @@ int packet_get(struct gps_device_t *session, unsigned int waiting)
if (session->packet_state == GROUND_STATE) {
character_discard(session);
} else if (session->packet_state == NMEA_RECOGNIZED) {
- int checksum_ok = 1;
- unsigned char csum[3];
- unsigned char *trailer = session->inbufptr-5;
+ bool checksum_ok = true;
+ char csum[3];
+ char *trailer = (char *)session->inbufptr-5;
if (*trailer == '*') {
unsigned int n, crc = 0;
- for (n = 1; session->inbuffer + n < trailer; n++)
+ for (n = 1; (char *)session->inbuffer + n < trailer; n++)
crc ^= session->inbuffer[n];
(void)snprintf(csum, sizeof(csum), "%02X", crc);
checksum_ok = (toupper(csum[0])==toupper(trailer[1])
@@ -557,9 +556,9 @@ int packet_get(struct gps_device_t *session, unsigned int waiting)
packet_discard(session);
} else if (session->packet_state == SIRF_RECOGNIZED) {
unsigned char *trailer = session->inbufptr-4;
- unsigned int checksum = (trailer[0] << 8) | trailer[1];
+ unsigned int checksum = (unsigned)((trailer[0] << 8) | trailer[1]);
unsigned int n, crc = 0;
- for (n = 4; n < (size_t)(trailer - session->inbuffer); n++)
+ for (n = 4; n < (unsigned)(trailer - session->inbuffer); n++)
crc += (int)session->inbuffer[n];
crc &= 0x7fff;
if (checksum == crc)
@@ -575,27 +574,27 @@ int packet_get(struct gps_device_t *session, unsigned int waiting)
#endif /* TSIP_ENABLE */
#ifdef ZODIAC_ENABLE
} else if (session->packet_state == ZODIAC_RECOGNIZED) {
- #define getw(i) (short)(session->inbuffer[2*(i)] | (session->inbuffer[2*(i)+1] << 8))
+ #define getword(i) (short)(session->inbuffer[2*(i)] | (session->inbuffer[2*(i)+1] << 8))
short len, n, sum;
- len = getw(2);
+ len = getword(2);
for (n = sum = 0; n < len; n++)
- sum += getw(5+n);
+ sum += getword(5+n);
sum *= -1;
- if (len == 0 || sum == getw(5 + len)) {
+ if (len == 0 || sum == getword(5 + len)) {
packet_accept(session, ZODIAC_PACKET);
} else {
gpsd_report(4,
"Zodiac Data checksum 0x%hx over length %hd, expecting 0x%hx\n",
- sum, len, getw(5 + len));
+ sum, len, getword(5 + len));
}
session->packet_state = GROUND_STATE;
packet_discard(session);
-#undef getw
+#undef getword
#endif /* ZODIAC_ENABLE */
}
}
- return session->outbuflen;
+ return (int)session->outbuflen;
}
void packet_reset(struct gps_device_t *session)
diff --git a/sirf.c b/sirf.c
index 844023f7..d481d812 100644
--- a/sirf.c
+++ b/sirf.c
@@ -106,10 +106,10 @@ static bool sirf_to_nmea(int ttyfd, speed_t speed)
return (sirf_write(ttyfd, msg));
}
-#define getb(off) buf[off]
-#define getw(off) ((short)((getb(off) << 8) | getb(off+1)))
-#define getl(off) ((int)((getb(off) << 24) | (getb(off+1) << 16) \
- | (getb(off+3) << 8) | getb(off+4)))
+#define getbyte(off) buf[off]
+#define getword(off) ((short)((getbyte(off) << 8) | getbyte(off+1)))
+#define getlong(off) ((int)((getbyte(off) << 24) | (getbyte(off+1) << 16) \
+ | (getbyte(off+3) << 8) | getbyte(off+4)))
static void sirfbin_mode(struct gps_device_t *session, int mode)
{
@@ -165,18 +165,18 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
{
case 0x02: /* Measure Navigation Data Out */
mask = 0;
- session->gpsdata.satellites_used = (int)getb(28);
+ session->gpsdata.satellites_used = (int)getbyte(28);
memset(session->gpsdata.used,0,sizeof(session->gpsdata.used));
for (i = 0; i < MAXCHANNELS; i++)
- session->gpsdata.used[i] = (int)getb(29+i);
+ session->gpsdata.used[i] = (int)getbyte(29+i);
if ((session->driverstate & (SIRF_GE_232 | UBLOX))==0) {
/* position/velocity is bytes 1-18 */
ecef_to_wgs84fix(&session->gpsdata.fix,
- (double)getl(1), (double)getl(5), (double)getl(9),
- (int)getw(13)/8.0, (int)getw(15)/8.0, (int)getw(17)/8.0);
+ (double)getlong(1), (double)getlong(5), (double)getlong(9),
+ (int)getword(13)/8.0, (int)getword(15)/8.0, (int)getword(17)/8.0);
/* WGS 84 geodesy parameters */
/* fix status is byte 19 */
- navtype = (int)getb(19);
+ navtype = (int)getbyte(19);
session->gpsdata.status = STATUS_NO_FIX;
session->gpsdata.fix.mode = MODE_NO_FIX;
if ((navtype & 0x80) != 0)
@@ -194,7 +194,7 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
/* byte 20 is HDOP, see below */
/* byte 21 is "mode 2", not clear how to interpret that */
session->gpsdata.fix.time = session->gpsdata.sentence_time
- = gpstime_to_unix((int)getw(22), (int)getl(24)*1e-2) - session->context->leap_seconds;
+ = gpstime_to_unix((int)getword(22), (int)getlong(24)*1e-2) - session->context->leap_seconds;
#ifdef NTPSHM_ENABLE
if (session->gpsdata.fix.mode > MODE_NO_FIX) {
if ((session->time_seen & TIME_SEEN_GPS_2) == 0)
@@ -208,7 +208,7 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
gpsd_binary_fix_dump(session, buf2, (int)sizeof(buf2));
/* fix quality data */
- session->gpsdata.hdop = (int)getb(20)/5.0;
+ session->gpsdata.hdop = (int)getbyte(20)/5.0;
session->gpsdata.pdop = session->gpsdata.vdop = 0.0;
if (session->gpsdata.satellites > 0)
dop(session->gpsdata.satellites_used, &session->gpsdata);
@@ -223,27 +223,27 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
case 0x04: /* Measured tracker data out */
gpsd_zero_satellites(&session->gpsdata);
session->gpsdata.sentence_time
- = gpstime_to_unix((int)getw(1), (int)getl(3)*1e-2) - session->context->leap_seconds;
+ = gpstime_to_unix((int)getword(1), (int)getlong(3)*1e-2) - session->context->leap_seconds;
for (i = st = 0; i < MAXCHANNELS; i++) {
int off = 8 + 15 * i;
bool good;
- session->gpsdata.PRN[st] = (int)getb(off);
- session->gpsdata.azimuth[st] = (int)(((int)getb(off+1)*3)/2.0);
- session->gpsdata.elevation[st] = (int)((int)getb(off+2)/2.0);
+ session->gpsdata.PRN[st] = (int)getbyte(off);
+ session->gpsdata.azimuth[st] = (int)(((int)getbyte(off+1)*3)/2.0);
+ session->gpsdata.elevation[st] = (int)((int)getbyte(off+2)/2.0);
cn = 0;
for (j = 0; j < 10; j++)
- cn += (int)getb(off+5+j);
+ cn += (int)getbyte(off+5+j);
session->gpsdata.ss[st] = cn/10;
good = session->gpsdata.PRN[st]!=0 &&
session->gpsdata.azimuth[st]!=0 &&
session->gpsdata.elevation[st]!=0;
#ifdef __UNUSED__
gpsd_report(4, "PRN=%2d El=%3.2f Az=%3.2f ss=%3d stat=%04x %c\n",
- getb(off),
- getb(off+2)/2.0,
- (getb(off+1)*3)/2.0,
+ getbyte(off),
+ getbyte(off+2)/2.0,
+ (getbyte(off+1)*3)/2.0,
cn/10,
- getw(off+3),
+ getword(off+3),
good ? '*' : ' ');
#endif /* UNUSED */
if (good!=0)
@@ -326,18 +326,18 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
*/
{
unsigned int pageid, subframe, leap, words[10];
- unsigned int chan = (unsigned int)getb(1);
- unsigned int svid = (unsigned int)getb(2);
- words[0] = (unsigned int)getl(3);
- words[1] = (unsigned int)getl(7);
- words[2] = (unsigned int)getl(11);
- words[3] = (unsigned int)getl(15);
- words[4] = (unsigned int)getl(19);
- words[5] = (unsigned int)getl(23);
- words[6] = (unsigned int)getl(27);
- words[7] = (unsigned int)getl(31);
- words[8] = (unsigned int)getl(35);
- words[9] = (unsigned int)getl(39);
+ unsigned int chan = (unsigned int)getbyte(1);
+ unsigned int svid = (unsigned int)getbyte(2);
+ words[0] = (unsigned int)getlong(3);
+ words[1] = (unsigned int)getlong(7);
+ words[2] = (unsigned int)getlong(11);
+ words[3] = (unsigned int)getlong(15);
+ words[4] = (unsigned int)getlong(19);
+ words[5] = (unsigned int)getlong(23);
+ words[6] = (unsigned int)getlong(27);
+ words[7] = (unsigned int)getlong(31);
+ words[8] = (unsigned int)getlong(35);
+ words[9] = (unsigned int)getlong(39);
gpsd_report(4, "50B (raw): CH=%d, SV=%d %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
chan, svid,
words[0], words[1], words[2], words[3], words[4],
@@ -427,40 +427,40 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
case 0x09: /* CPU Throughput */
gpsd_report(4,
"THR 0x09: SegStatMax=%.3f, SegStatLat=%3.f, AveTrkTime=%.3f, Last MS=%3.f\n",
- (float)getw(1)/186, (float)getw(3)/186,
- (float)getw(5)/186, (float)getw(7));
+ (float)getword(1)/186, (float)getword(3)/186,
+ (float)getword(5)/186, (float)getword(7));
return 0;
case 0x0a: /* Error ID Data */
- switch (getw(1))
+ switch (getword(1))
{
case 2:
- gpsd_report(4, "EID 0x0a type 2: Subframe %d error on PRN %ld\n", getl(9), getl(5));
+ gpsd_report(4, "EID 0x0a type 2: Subframe %d error on PRN %ld\n", getlong(9), getlong(5));
break;
case 4107:
- gpsd_report(4, "EID 0x0a type 4107: neither KF nor LSQ fix.\n", getl(5));
+ gpsd_report(4, "EID 0x0a type 4107: neither KF nor LSQ fix.\n", getlong(5));
break;
default:
- gpsd_report(4, "EID 0x0a: Error ID type %d\n", getw(1));
+ gpsd_report(4, "EID 0x0a: Error ID type %d\n", getword(1));
break;
}
return 0;
case 0x0b: /* Command Acknowledgement */
- gpsd_report(4, "ACK 0x0b: %02x\n",getb(1));
+ gpsd_report(4, "ACK 0x0b: %02x\n",getbyte(1));
return 0;
case 0x0c: /* Command NAcknowledgement */
- gpsd_report(4, "NAK 0x0c: %02x\n",getb(1));
+ gpsd_report(4, "NAK 0x0c: %02x\n",getbyte(1));
return 0;
case 0x0d: /* Visible List */
return 0;
case 0x12: /* OK To Send */
- gpsd_report(4, "OTS 0x12: send indicator = %d\n",getb(1));
+ gpsd_report(4, "OTS 0x12: send indicator = %d\n",getbyte(1));
return 0;
case 0x1b: /* DGPS status (undocumented) */
@@ -487,7 +487,7 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
* seem to be the case. Instead, we do our own computation
* of geoid separation now.
*/
- navtype = (int)getw(3);
+ navtype = (int)getword(3);
session->gpsdata.status = STATUS_NO_FIX;
session->gpsdata.fix.mode = MODE_NO_FIX;
if ((navtype & 0x80) != 0)
@@ -513,13 +513,13 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
* UTC second 2 2
* 11 8
*/
- session->gpsdata.nmea_date.tm_year = (int)getw(11);
- session->gpsdata.nmea_date.tm_mon = (int)getb(13)-1;
- session->gpsdata.nmea_date.tm_mday = (int)getb(14);
- session->gpsdata.nmea_date.tm_hour = (int)getb(15);
- session->gpsdata.nmea_date.tm_min = (int)getb(16);
+ session->gpsdata.nmea_date.tm_year = (int)getword(11);
+ session->gpsdata.nmea_date.tm_mon = (int)getbyte(13)-1;
+ session->gpsdata.nmea_date.tm_mday = (int)getbyte(14);
+ session->gpsdata.nmea_date.tm_hour = (int)getbyte(15);
+ session->gpsdata.nmea_date.tm_min = (int)getbyte(16);
session->gpsdata.nmea_date.tm_sec = 0;
- session->gpsdata.subseconds = (int)getw(17)*1e-3;
+ session->gpsdata.subseconds = (int)getword(17)*1e-3;
session->gpsdata.fix.time = session->gpsdata.sentence_time
= (double)mktime(&session->gpsdata.nmea_date)+session->gpsdata.subseconds;
gpsd_report(5, "MID 41 UTC: %lf\n", session->gpsdata.fix.time);
@@ -534,16 +534,16 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
}
#endif /* NTPSHM_ENABLE */
/* skip 4 bytes of satellite map */
- session->gpsdata.fix.latitude = getl(23)*1e-7;
- session->gpsdata.fix.longitude = getl(27)*1e-7;
+ session->gpsdata.fix.latitude = getlong(23)*1e-7;
+ session->gpsdata.fix.longitude = getlong(27)*1e-7;
/* skip 4 bytes of altitude from ellipsoid */
mask = TIME_SET | LATLON_SET | STATUS_SET | MODE_SET;
- session->gpsdata.fix.altitude = getl(31)*1e-2;
+ session->gpsdata.fix.altitude = getlong(31)*1e-2;
/* skip 1 byte of map datum */
- session->gpsdata.fix.speed = (int)getw(36)*1e-2;
- session->gpsdata.fix.track = (int)getw(38)*1e-2;
+ session->gpsdata.fix.speed = (int)getword(36)*1e-2;
+ session->gpsdata.fix.track = (int)getword(38)*1e-2;
/* skip 2 bytes of magnetic variation */
- session->gpsdata.fix.climb = (int)getw(42)*1e-2;
+ session->gpsdata.fix.climb = (int)getword(42)*1e-2;
/* HDOP should be available at byte 89, but in 231 it's zero. */
gpsd_binary_fix_dump(session, buf2, (int)sizeof(buf2));
gpsd_report(3, "<= GPS: %s", buf2);
@@ -579,15 +579,15 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
* second."
*/
mask = 0;
- gpsd_report(4, "PPS 0x34: Status = 0x%02x\n", getb(14));
- if (((int)getb(14) & 0x07) == 0x07) { /* valid UTC time? */
- session->gpsdata.nmea_date.tm_hour = (int)getb(1);
- session->gpsdata.nmea_date.tm_min = (int)getb(2);
- session->gpsdata.nmea_date.tm_sec = (int)getb(3);
- session->gpsdata.nmea_date.tm_mday = (int)getb(4);
- session->gpsdata.nmea_date.tm_mon = (int)getb(5) - 1;
- session->gpsdata.nmea_date.tm_year = (int)getw(6) - 1900;
- session->context->leap_seconds = (int)getw(8);
+ gpsd_report(4, "PPS 0x34: Status = 0x%02x\n", getbyte(14));
+ if (((int)getbyte(14) & 0x07) == 0x07) { /* valid UTC time? */
+ session->gpsdata.nmea_date.tm_hour = (int)getbyte(1);
+ session->gpsdata.nmea_date.tm_min = (int)getbyte(2);
+ session->gpsdata.nmea_date.tm_sec = (int)getbyte(3);
+ session->gpsdata.nmea_date.tm_mday = (int)getbyte(4);
+ session->gpsdata.nmea_date.tm_mon = (int)getbyte(5) - 1;
+ session->gpsdata.nmea_date.tm_year = (int)getword(6) - 1900;
+ session->context->leap_seconds = (int)getword(8);
session->context->valid = LEAP_SECOND_VALID;
#ifdef NTPSHM_ENABLE
if ((session->time_seen & TIME_SEEN_UTC_2) == 0)
@@ -605,15 +605,15 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
/* this packet is only sent by uBlox firmware from version 1.32 */
mask = LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET | CLIMB_SET |
STATUS_SET | MODE_SET | HDOP_SET | VDOP_SET | PDOP_SET;
- session->gpsdata.fix.latitude = getl(1) * RAD_2_DEG * 1e-8;
- session->gpsdata.fix.longitude = getl(5) * RAD_2_DEG * 1e-8;
+ session->gpsdata.fix.latitude = getlong(1) * RAD_2_DEG * 1e-8;
+ session->gpsdata.fix.longitude = getlong(5) * RAD_2_DEG * 1e-8;
session->gpsdata.fix.separation = wgs84_separation(session->gpsdata.fix.latitude, session->gpsdata.fix.longitude);
- session->gpsdata.fix.altitude = getl(9) * 1e-3 - session->gpsdata.fix.separation;
- session->gpsdata.fix.speed = getl(13) * 1e-3;
- session->gpsdata.fix.climb = getl(17) * 1e-3;
- session->gpsdata.fix.track = getl(21) * RAD_2_DEG * 1e-8;
+ session->gpsdata.fix.altitude = getlong(9) * 1e-3 - session->gpsdata.fix.separation;
+ session->gpsdata.fix.speed = getlong(13) * 1e-3;
+ session->gpsdata.fix.climb = getlong(17) * 1e-3;
+ session->gpsdata.fix.track = getlong(21) * RAD_2_DEG * 1e-8;
- navtype = (int)getb(25);
+ navtype = (int)getbyte(25);
session->gpsdata.status = STATUS_NO_FIX;
session->gpsdata.fix.mode = MODE_NO_FIX;
if ((navtype & 0x80) != 0)
@@ -629,13 +629,13 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
if ((navtype & 0x40) != 0) { /* UTC corrected timestamp? */
mask |= TIME_SET;
- session->gpsdata.nmea_date.tm_year = (int)getw(26) - 1900;
- session->gpsdata.nmea_date.tm_mon = (int)getb(28) - 1;
- session->gpsdata.nmea_date.tm_mday = (int)getb(29);
- session->gpsdata.nmea_date.tm_hour = (int)getb(30);
- session->gpsdata.nmea_date.tm_min = (int)getb(31);
+ session->gpsdata.nmea_date.tm_year = (int)getword(26) - 1900;
+ session->gpsdata.nmea_date.tm_mon = (int)getbyte(28) - 1;
+ session->gpsdata.nmea_date.tm_mday = (int)getbyte(29);
+ session->gpsdata.nmea_date.tm_hour = (int)getbyte(30);
+ session->gpsdata.nmea_date.tm_min = (int)getbyte(31);
session->gpsdata.nmea_date.tm_sec = 0;
- session->gpsdata.subseconds = ((unsigned short)getw(32))*1e-3;
+ session->gpsdata.subseconds = ((unsigned short)getword(32))*1e-3;
session->gpsdata.fix.time = session->gpsdata.sentence_time
= (double)mkgmtime(&session->gpsdata.nmea_date)+session->gpsdata.subseconds;
#ifdef NTPSHM_ENABLE
@@ -650,11 +650,11 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len)
}
gpsd_binary_fix_dump(session, buf2, (int)sizeof(buf2));
- session->gpsdata.gdop = (int)getb(34) / 5.0;
- session->gpsdata.pdop = (int)getb(35) / 5.0;
- session->gpsdata.hdop = (int)getb(36) / 5.0;
- session->gpsdata.vdop = (int)getb(37) / 5.0;
- session->gpsdata.tdop = (int)getb(38) / 5.0;
+ session->gpsdata.gdop = (int)getbyte(34) / 5.0;
+ session->gpsdata.pdop = (int)getbyte(35) / 5.0;
+ session->gpsdata.hdop = (int)getbyte(36) / 5.0;
+ session->gpsdata.vdop = (int)getbyte(37) / 5.0;
+ session->gpsdata.tdop = (int)getbyte(38) / 5.0;
gpsd_binary_quality_dump(session,
buf2 + strlen(buf2),
(int)(sizeof(buf2)-strlen(buf2)));
diff --git a/sirfmon.c b/sirfmon.c
index 763c260e..7a8ce12b 100644
--- a/sirfmon.c
+++ b/sirfmon.c
@@ -91,14 +91,14 @@ static char *sbasvec[] =
"Software",
};
-#define getb(off) (buf[off])
-#define getw(off) ((short)((getb(off) << 8) | getb(off+1)))
-#define getl(off) ((int)((getb(off) << 24) | (getb(off+1) << 16) \
- | (getb(off+3) << 8) | getb(off+4)))
+#define getbyte(off) (buf[off])
+#define getword(off) ((short)((getbyte(off) << 8) | getbyte(off+1)))
+#define getlong(off) ((int)((getbyte(off) << 24) | (getbyte(off+1) << 16) \
+ | (getbyte(off+3) << 8) | getbyte(off+4)))
-#define putb(off,b) { buf[4+off] = (unsigned char)(b); }
-#define putw(off,w) { putb(off,(w) >> 8); putb(off+1,w); }
-#define putl(off,l) { putw(off,(l) >> 16); putw(off+2,l); }
+#define putbyte(off,b) { buf[4+off] = (unsigned char)(b); }
+#define putword(off,w) { putbyte(off,(w) >> 8); putbyte(off+1,w); }
+#define putlong(off,l) { putword(off,(l) >> 16); putword(off+2,l); }
static struct termios ttyset;
static WINDOW *mid2win, *mid4win, *mid6win, *mid7win, *mid9win, *mid13win;
@@ -231,26 +231,26 @@ static void decode_sirf(unsigned char buf[], int len)
{
case 0x02: /* Measured Navigation Data */
(void)wmove(mid2win, 1,6);
- (void)wprintw(mid2win, "%8d %8d %8d",getl(1),getl(5),getl(9));
+ (void)wprintw(mid2win, "%8d %8d %8d",getlong(1),getlong(5),getlong(9));
(void)wmove(mid2win, 2,6);
(void)wprintw(mid2win, "%8.1f %8.1f %8.1f",
- (double)getw(13)/8,(double)getw(15)/8,(double)getw(17)/8);
- decode_ecef((double)getl(1),(double)getl(5),(double)getl(9),
- (double)getw(13)/8,(double)getw(15)/8,(double)getw(17)/8);
- decode_time((int)getw(22),getl(24));
+ (double)getword(13)/8,(double)getword(15)/8,(double)getword(17)/8);
+ decode_ecef((double)getlong(1),(double)getlong(5),(double)getlong(9),
+ (double)getword(13)/8,(double)getword(15)/8,(double)getword(17)/8);
+ decode_time((int)getword(22),getlong(24));
/* line 4 */
(void)wmove(mid2win, 4,49);
- (void)wprintw(mid2win, "%4.1f",(double)getb(20)/5); /* HDOP */
+ (void)wprintw(mid2win, "%4.1f",(double)getbyte(20)/5); /* HDOP */
(void)wmove(mid2win, 4,58);
- (void)wprintw(mid2win, "%02x",getb(19)); /* Mode 1 */
+ (void)wprintw(mid2win, "%02x",getbyte(19)); /* Mode 1 */
(void)wmove(mid2win, 4,72);
- (void)wprintw(mid2win, "%02x",getb(21)); /* Mode 2 */
+ (void)wprintw(mid2win, "%02x",getbyte(21)); /* Mode 2 */
(void)wmove(mid2win, 5,7);
- nfix = (int)getb(28);
+ nfix = (int)getbyte(28);
(void)wprintw(mid2win, "%d = ",nfix); /* SVs in fix */
for (i = 0; i < MAXCHANNELS; i++) { /* SV list */
if (i < nfix)
- (void)wprintw(mid2win, "%3d",fix[i] = (int)getb(29+i));
+ (void)wprintw(mid2win, "%3d",fix[i] = (int)getbyte(29+i));
else
(void)wprintw(mid2win, " ");
}
@@ -258,20 +258,20 @@ static void decode_sirf(unsigned char buf[], int len)
break;
case 0x04: /* Measured Tracking Data */
- decode_time((int)getw(1),getl(3));
- ch = (int)getb(7);
+ decode_time((int)getword(1),getlong(3));
+ ch = (int)getbyte(7);
for (i = 0; i < ch; i++) {
int sv,st;
off = 8 + 15 * i;
(void)wmove(mid4win, i+2, 3);
- sv = (int)getb(off);
+ sv = (int)getbyte(off);
(void)wprintw(mid4win, " %3d",sv);
- (void)wprintw(mid4win, " %3d%3d %04x",((int)getb(off+1)*3)/2,(int)getb(off+2)/2,(int)getw(off+3));
+ (void)wprintw(mid4win, " %3d%3d %04x",((int)getbyte(off+1)*3)/2,(int)getbyte(off+2)/2,(int)getword(off+3));
st = ' ';
- if ((int)getw(off+3) == 0xbf)
+ if ((int)getword(off+3) == 0xbf)
st = 'T';
for (j = 0; j < nfix; j++)
if (sv == fix[j]) {
@@ -282,7 +282,7 @@ static void decode_sirf(unsigned char buf[], int len)
cn = 0;
for (j = 0; j < 10; j++)
- cn += (int)getb(off+5+j);
+ cn += (int)getbyte(off+5+j);
(void)wprintw(mid4win, "%5.1f %c",(double)cn/10,st);
@@ -295,18 +295,18 @@ static void decode_sirf(unsigned char buf[], int len)
#ifdef __UNUSED__
case 0x05: /* raw track data */
for (off = 1; off < len; off += 51) {
- ch = getl(off);
+ ch = getlong(off);
(void)wmove(mid4win, ch+2, 19);
cn = 0;
for (j = 0; j < 10; j++)
- cn += getb(off+34+j);
+ cn += getbyte(off+34+j);
printw("%5.1f",(double)cn/10);
- printw("%9d%3d%5d",getl(off+8),(int)getw(off+12),(int)getw(off+14));
+ printw("%9d%3d%5d",getlong(off+8),(int)getword(off+12),(int)getword(off+14));
printw("%8.5f %10.5f",
- (double)getl(off+16)/65536,(double)getl(off+20)/1024);
+ (double)getlong(off+16)/65536,(double)getlong(off+20)/1024);
}
(void)wprintw(debugwin, "RTD 0x05=");
break;
@@ -318,26 +318,26 @@ static void decode_sirf(unsigned char buf[], int len)
break;
case 0x07: /* Response - Clock Status Data */
- decode_time((int)getw(1),getl(3));
- display(mid7win, 1, 5, "%2d", getb(7)); /* SVs */
- display(mid7win, 1, 16, "%lu", getl(8)); /* Clock drift */
- display(mid7win, 1, 29, "%lu", getl(12)); /* Clock Bias */
- display(mid7win, 2, 21, "%lu", getl(16)); /* Estimated Time */
+ decode_time((int)getword(1),getlong(3));
+ display(mid7win, 1, 5, "%2d", getbyte(7)); /* SVs */
+ display(mid7win, 1, 16, "%lu", getlong(8)); /* Clock drift */
+ display(mid7win, 1, 29, "%lu", getlong(12)); /* Clock Bias */
+ display(mid7win, 2, 21, "%lu", getlong(16)); /* Estimated Time */
(void)wprintw(debugwin, "CSD 0x07=");
break;
case 0x08: /* 50 BPS data */
- ch = (int)getb(1);
+ ch = (int)getbyte(1);
display(mid4win, ch, 27, "Y");
(void)wprintw(debugwin, "50B 0x08=");
subframe_enabled = true;
break;
case 0x09: /* Throughput */
- display(mid9win, 1, 6, "%.3f",(double)getw(1)/186); /*SegStatMax*/
- display(mid9win, 1, 18, "%.3f",(double)getw(3)/186); /*SegStatLat*/
- display(mid9win, 1, 31, "%.3f",(double)getw(5)/186); /*SegStatTime*/
- display(mid9win, 1, 42, "%3d",(int)getw(7)); /* Last Millisecond */
+ display(mid9win, 1, 6, "%.3f",(double)getword(1)/186); /*SegStatMax*/
+ display(mid9win, 1, 18, "%.3f",(double)getword(3)/186); /*SegStatLat*/
+ display(mid9win, 1, 31, "%.3f",(double)getword(5)/186); /*SegStatTime*/
+ display(mid9win, 1, 42, "%3d",(int)getword(7)); /* Last Millisecond */
(void)wprintw(debugwin, "THR 0x09=");
break;
@@ -350,11 +350,11 @@ static void decode_sirf(unsigned char buf[], int len)
break;
case 0x0d: /* Visible List */
- display(mid13win, 1, 6, "%d",getb(1));
+ display(mid13win, 1, 6, "%d",getbyte(1));
(void)wmove(mid13win, 1, 10);
for (i = 0; i < MAXCHANNELS; i++) {
- if (i < (int)getb(1))
- (void)wprintw(mid13win, " %2d",getb(2 + 5 * i));
+ if (i < (int)getbyte(1))
+ (void)wprintw(mid13win, " %2d",getbyte(2 + 5 * i));
else
(void)wprintw(mid13win, " ");
@@ -364,36 +364,36 @@ static void decode_sirf(unsigned char buf[], int len)
break;
case 0x13:
-#define YESNO(n) (((int)getb(n) != 0)?'Y':'N')
- display(mid19win, 1, 20, "%d", getb(5)); /* Alt. hold mode */
- display(mid19win, 2, 20, "%d", getb(6)); /* Alt. hold source*/
- display(mid19win, 3, 20, "%dm", (int)getw(7)); /* Alt. source input */
- display(mid19win, 4, 20, "%d", getb(9)); /* Degraded mode*/
- display(mid19win, 5, 20, "%dsec", getb(10)); /* Degraded timeout*/
- display(mid19win, 6, 20, "%dsec",getb(11)); /* DR timeout*/
+#define YESNO(n) (((int)getbyte(n) != 0)?'Y':'N')
+ display(mid19win, 1, 20, "%d", getbyte(5)); /* Alt. hold mode */
+ display(mid19win, 2, 20, "%d", getbyte(6)); /* Alt. hold source*/
+ display(mid19win, 3, 20, "%dm", (int)getword(7)); /* Alt. source input */
+ display(mid19win, 4, 20, "%d", getbyte(9)); /* Degraded mode*/
+ display(mid19win, 5, 20, "%dsec", getbyte(10)); /* Degraded timeout*/
+ display(mid19win, 6, 20, "%dsec",getbyte(11)); /* DR timeout*/
display(mid19win, 7, 20, "%c", YESNO(12));/* Track smooth mode*/
display(mid19win, 8, 20, "%c", YESNO(13)); /* Static Nav.*/
- display(mid19win, 9, 20, "0x%x", getb(14)); /* 3SV Least Squares*/
- display(mid19win, 10,20, "0x%x", getb(19)); /* DOP Mask mode*/
- display(mid19win, 11,20, "0x%x", (int)getw(20)); /* Nav. Elev. mask*/
- display(mid19win, 12,20, "0x%x", getb(22)); /* Nav. Power mask*/
- display(mid19win, 13,20, "0x%x", getb(27)); /* DGPS Source*/
- display(mid19win, 14,20, "0x%x", getb(28)); /* DGPS Mode*/
- display(mid19win, 15,20, "%dsec",getb(29)); /* DGPS Timeout*/
+ display(mid19win, 9, 20, "0x%x", getbyte(14)); /* 3SV Least Squares*/
+ display(mid19win, 10,20, "0x%x", getbyte(19)); /* DOP Mask mode*/
+ display(mid19win, 11,20, "0x%x", (int)getword(20)); /* Nav. Elev. mask*/
+ display(mid19win, 12,20, "0x%x", getbyte(22)); /* Nav. Power mask*/
+ display(mid19win, 13,20, "0x%x", getbyte(27)); /* DGPS Source*/
+ display(mid19win, 14,20, "0x%x", getbyte(28)); /* DGPS Mode*/
+ display(mid19win, 15,20, "%dsec",getbyte(29)); /* DGPS Timeout*/
display(mid19win, 1, 42, "%c", YESNO(34));/* LP Push-to-Fix */
- display(mid19win, 2, 42, "%dms", getl(35)); /* LP On Time */
- display(mid19win, 3, 42, "%d", getl(39)); /* LP Interval */
+ display(mid19win, 2, 42, "%dms", getlong(35)); /* LP On Time */
+ display(mid19win, 3, 42, "%d", getlong(39)); /* LP Interval */
display(mid19win, 4, 42, "%c", YESNO(43));/* User Tasks enabled */
- display(mid19win, 5, 42, "%d", getl(44)); /* User Task Interval */
+ display(mid19win, 5, 42, "%d", getlong(44)); /* User Task Interval */
display(mid19win, 6, 42, "%c", YESNO(48));/* LP Power Cycling Enabled */
- display(mid19win, 7, 42, "%d", getl(49));/* LP Max Acq Search Time */
- display(mid19win, 8, 42, "%d", getl(53));/* LP Max Off Time */
+ display(mid19win, 7, 42, "%d", getlong(49));/* LP Max Acq Search Time */
+ display(mid19win, 8, 42, "%d", getlong(53));/* LP Max Off Time */
display(mid19win, 9, 42, "%c", YESNO(57));/* APM Enabled */
- display(mid19win,10, 42, "%d", (int)getw(58));/* # of fixes */
- display(mid19win,11, 42, "%d", (int)getw(60));/* Time Between fixes */
- display(mid19win,12, 42, "%d", getb(62));/* H/V Error Max */
- display(mid19win,13, 42, "%d", getb(63));/* Response Time Max */
- display(mid19win,14, 42, "%d", getb(64));/* Time/Accu & Duty Cycle Priority */
+ display(mid19win,10, 42, "%d", (int)getword(58));/* # of fixes */
+ display(mid19win,11, 42, "%d", (int)getword(60));/* Time Between fixes */
+ display(mid19win,12, 42, "%d", getbyte(62));/* H/V Error Max */
+ display(mid19win,13, 42, "%d", getbyte(63));/* Response Time Max */
+ display(mid19win,14, 42, "%d", getbyte(64));/* Time/Accu & Duty Cycle Priority */
#undef YESNO
dispmode = !dispmode;
break;
@@ -439,10 +439,10 @@ static void decode_sirf(unsigned char buf[], int len)
total 2 x 12 = 24 bytes
******************************************************************/
- display(mid27win, 1, 14, "%d (%s)", getb(1), sbasvec[(int)getb(1)]);
+ display(mid27win, 1, 14, "%d (%s)", getbyte(1), sbasvec[(int)getbyte(1)]);
for (i = j = 0; i < MAXCHANNELS; i++) {
- if (/*@i1@*/getb(16+2*i) != '\0') {
- (void)wprintw(mid27win, "%d=%d ", getb(16+2*i), getb(16+2*i+1));
+ if (/*@i1@*/getbyte(16+2*i) != '\0') {
+ (void)wprintw(mid27win, "%d=%d ", getbyte(16+2*i), getbyte(16+2*i+1));
j++;
}
}
@@ -461,18 +461,18 @@ static void decode_sirf(unsigned char buf[], int len)
case 0x62:
attrset(A_BOLD);
move(2,40);
- printw("%9.5f %9.5f",(double)(RAD2DEG*1e8*getl(1)),
- (double)(RAD2DEG*1e8*getl(5)));
+ printw("%9.5f %9.5f",(double)(RAD2DEG*1e8*getlong(1)),
+ (double)(RAD2DEG*1e8*getlong(5)));
move(2,63);
- printw("%8d",getl(9)/1000);
+ printw("%8d",getlong(9)/1000);
move(3,63);
- printw("%8.1f",(double)getl(17)/1000);
+ printw("%8.1f",(double)getlong(17)/1000);
move(4,54);
- if (getl(13) > 50) {
- double heading = RAD2DEG*1e8*getl(21);
+ if (getlong(13) > 50) {
+ double heading = RAD2DEG*1e8*getlong(21);
if (heading < 0)
heading += 360;
printw("%5.1f",heading);
@@ -480,14 +480,14 @@ static void decode_sirf(unsigned char buf[], int len)
printw(" 0.0");
move(4,63);
- printw("%8.1f",(double)getl(13)/1000);
+ printw("%8.1f",(double)getlong(13)/1000);
attrset(A_NORMAL);
move(5,13);
printw("%04d-%02d-%02d %02d:%02d:%02d.%02d",
- (int)getw(26),getb(28),getb(29),getb(30),getb(31),
- (unsigned short)getw(32)/1000,
- ((unsigned short)getw(32)%1000)/10);
+ (int)getword(26),getbyte(28),getbyte(29),getbyte(30),getbyte(31),
+ (unsigned short)getword(32)/1000,
+ ((unsigned short)getword(32)%1000)/10);
{
struct timeval clk,gps;
struct tm tm;
@@ -495,15 +495,15 @@ static void decode_sirf(unsigned char buf[], int len)
gettimeofday(&clk,NULL);
memset(&tm,0,sizeof(tm));
- tm.tm_sec = (unsigned short)getw(32)/1000;
- tm.tm_min = getb(31);
- tm.tm_hour = getb(30);
- tm.tm_mday = getb(29);
- tm.tm_mon = getb(28) - 1;
- tm.tm_year = (int)getw(26) - 1900;
+ tm.tm_sec = (unsigned short)getword(32)/1000;
+ tm.tm_min = getbyte(31);
+ tm.tm_hour = getbyte(30);
+ tm.tm_mday = getbyte(29);
+ tm.tm_mon = getbyte(28) - 1;
+ tm.tm_year = (int)getword(26) - 1900;
gps.tv_sec = mkgmtime(&tm);
- gps.tv_usec = (((unsigned short)getw(32)%1000)/10) * 10000;
+ gps.tv_usec = (((unsigned short)getword(32)%1000)/10) * 10000;
move(5,2);
printw(" ");
@@ -796,18 +796,18 @@ static bool sendpkt(unsigned char *buf, size_t len, char *device)
ssize_t st;
size_t i;
- putb(-4,START1); /* start of packet */
- putb(-3,START2);
- putw(-2,len); /* length */
+ putbyte(-4,START1); /* start of packet */
+ putbyte(-3,START2);
+ putword(-2,len); /* length */
csum = 0;
for (i = 0; i < len; i++)
csum += (int)buf[4 + i];
csum &= 0x7fff;
- putw(len,csum); /* checksum */
- putb(len + 2,END1); /* end of packet */
- putb(len + 3,END2);
+ putword(len,csum); /* checksum */
+ putbyte(len + 2,END1); /* end of packet */
+ putbyte(len + 3,END2);
len += 8;
(void)wprintw(debugwin, ">>>");
@@ -836,11 +836,11 @@ static bool sendpkt(unsigned char *buf, size_t len, char *device)
*
*****************************************************************************/
-static int tzoffset(void)
+static long tzoffset(void)
{
time_t now = time(NULL);
struct tm tm;
- int res = 0;
+ long res = 0;
/*@ -unrecog **/
tzset();
@@ -1101,8 +1101,8 @@ int main (int argc, char **argv)
/*@i@*/FD_ZERO(&select_set);
/* probe for version */
- putb(0, 0x84);
- putb(1, 0x0);
+ putbyte(0, 0x84);
+ putbyte(1, 0x0);
(void)sendpkt(buf, 2, device);
for (;;) {
@@ -1165,26 +1165,26 @@ int main (int argc, char **argv)
{
case 'a': /* toggle 50bps subframe data */
(void)memset(buf, '\0', sizeof(buf));
- putb(0, 0x80);
- putb(23, 12);
- putb(24, subframe_enabled ? 0x00 : 0x10);
+ putbyte(0, 0x80);
+ putbyte(23, 12);
+ putbyte(24, subframe_enabled ? 0x00 : 0x10);
(void)sendpkt(buf, 25, device);
break;
case 'b':
if (serial) {
- v = atoi(line+1);
+ v = (unsigned)atoi(line+1);
for (ip=rates; ip<rates+sizeof(rates)/sizeof(rates[0]);ip++)
if (v == *ip)
goto goodspeed;
break;
goodspeed:
- putb(0, 0x86);
- putl(1, v); /* new baud rate */
- putb(5, 8); /* 8 data bits */
- putb(6, stopbits); /* 1 stop bit */
- putb(7, 0); /* no parity */
- putb(8, 0); /* reserved */
+ putbyte(0, 0x86);
+ putlong(1, v); /* new baud rate */
+ putbyte(5, 8); /* 8 data bits */
+ putbyte(6, stopbits); /* 1 stop bit */
+ putbyte(7, 0); /* no parity */
+ putbyte(8, 0); /* reserved */
(void)sendpkt(buf, 9, device);
(void)usleep(50000);
(void)set_speed(bps = v, stopbits);
@@ -1197,8 +1197,8 @@ int main (int argc, char **argv)
break;
case 'c': /* static navigation */
- putb(0,0x8f); /* id */
- putb(1, atoi(line+1));
+ putbyte(0,0x8f); /* id */
+ putbyte(1, atoi(line+1));
(void)sendpkt(buf, 2, device);
break;
@@ -1206,47 +1206,47 @@ int main (int argc, char **argv)
v = atoi(line+1);
if (v > 30)
break;
- putb(0,0xa6);
- putb(1,0);
- putb(2, 4); /* satellite picture */
- putb(3, v);
- putb(4, 0);
- putb(5, 0);
- putb(6, 0);
- putb(7, 0);
+ putbyte(0,0xa6);
+ putbyte(1,0);
+ putbyte(2, 4); /* satellite picture */
+ putbyte(3, v);
+ putbyte(4, 0);
+ putbyte(5, 0);
+ putbyte(6, 0);
+ putbyte(7, 0);
(void)sendpkt(buf, 8, device);
break;
case 'n': /* switch to NMEA */
- putb(0,0x81); /* id */
- putb(1,0x02); /* mode */
- putb(2,0x01); /* GGA */
- putb(3,0x01);
- putb(4,0x01); /* GLL */
- putb(5,0x01);
- putb(6,0x01); /* GSA */
- putb(7,0x01);
- putb(8,0x05); /* GSV */
- putb(9,0x01);
- putb(10,0x01); /* RNC */
- putb(11,0x01);
- putb(12,0x01); /* VTG */
- putb(13,0x01);
- putb(14,0x00); /* unused fields */
- putb(15,0x01);
- putb(16,0x00);
- putb(17,0x01);
- putb(18,0x00);
- putb(19,0x01);
- putb(20,0x00);
- putb(21,0x01);
- putw(22,bps);
+ putbyte(0,0x81); /* id */
+ putbyte(1,0x02); /* mode */
+ putbyte(2,0x01); /* GGA */
+ putbyte(3,0x01);
+ putbyte(4,0x01); /* GLL */
+ putbyte(5,0x01);
+ putbyte(6,0x01); /* GSA */
+ putbyte(7,0x01);
+ putbyte(8,0x05); /* GSV */
+ putbyte(9,0x01);
+ putbyte(10,0x01); /* RNC */
+ putbyte(11,0x01);
+ putbyte(12,0x01); /* VTG */
+ putbyte(13,0x01);
+ putbyte(14,0x00); /* unused fields */
+ putbyte(15,0x01);
+ putbyte(16,0x00);
+ putbyte(17,0x01);
+ putbyte(18,0x00);
+ putbyte(19,0x01);
+ putbyte(20,0x00);
+ putbyte(21,0x01);
+ putword(22,bps);
(void)sendpkt(buf, 24, device);
goto quit;
case 't': /* poll navigation params */
- putb(0,0x98);
- putb(1,0x00);
+ putbyte(0,0x98);
+ putbyte(1,0x00);
(void)sendpkt(buf, 2, device);
break;
@@ -1258,7 +1258,7 @@ int main (int argc, char **argv)
while (*p != '\0')
{
(void)sscanf(p,"%x",&v);
- putb(len,v);
+ putbyte(len,v);
len++;
while (*p != '\0' && !isspace(*p))
p++;
diff --git a/tsip.c b/tsip.c
index a1090a6d..57108777 100644
--- a/tsip.c
+++ b/tsip.c
@@ -22,14 +22,14 @@ union long_double {
double d;
};
-#define putb(off,b) { buf[off] = (unsigned char)(b); }
-#define putw(off,w) { putb(off,(w) >> 8); putb(off+1,w); }
-#define putl(off,l) { putw(off,(l) >> 16); putw(off+2,l); }
-
-#define getb(off) (buf[off])
-#define getw(off) ((short)((getb(off) << 8) | getb(off+1)))
-#define getl(off) ((int)((getb(off) << 24) | (getb(off+1) << 16) \
- | (getb(off+3) << 8) | getb(off+4)))
+#define putbyte(off,b) { buf[off] = (unsigned char)(b); }
+#define putword(off,w) { putbyte(off,(w) >> 8); putbyte(off+1,w); }
+#define putlong(off,l) { putword(off,(l) >> 16); putword(off+2,l); }
+
+#define getbyte(off) (buf[off])
+#define getword(off) ((short)((getbyte(off) << 8) | getbyte(off+1)))
+#define getl(off) ((int)((getbyte(off) << 24) | (getbyte(off+1) << 16) \
+ | (getbyte(off+3) << 8) | getbyte(off+4)))
#define getL(off) ((long long)(((long long)getl(off) << 32) | ((long long)getl(off+4) & 0xffffffffL)))
#define getf(off) (i_f.i = getl(off), i_f.f)
#define getd(off) (l_d.l = getL(off), l_d.d)
@@ -37,16 +37,18 @@ union long_double {
static int tsip_write(int fd, unsigned int id, unsigned char *buf, int len)
{
int i;
- unsigned char buf2[BUFSIZ];
+ char buf2[BUFSIZ];
buf2[0] = '\0';
for (i = 0; i < len; i++)
- (void)snprintf(buf2+strlen(buf2), sizeof(buf)-strlen(buf),
- "%02x", buf[i]);
+ (void)snprintf(buf2+strlen(buf2),
+ sizeof(buf2)-strlen(buf2),
+ "%02x", (unsigned)buf[i]);
gpsd_report(5, "Sent TSIP packet id 0x%02x: %s\n",id,buf2);
+ /*@ +charint @*/
buf2[0] = '\x10';
- buf2[1] = (unsigned char)id;
+ buf2[1] = (char)id;
if (write(fd,buf2,2) != 2)
return -1;
@@ -60,6 +62,7 @@ static int tsip_write(int fd, unsigned int id, unsigned char *buf, int len)
}
buf2[1] = '\x03';
+ /*@ -charint @*/
if (write(fd,buf2,2) != 2)
return -1;
@@ -74,10 +77,10 @@ static void tsip_initializer(struct gps_device_t *session)
gpsd_set_speed(session, session->gpsdata.baudrate, 'O', 1);
/* I/O Options */
- putb(0,0x1e); /* Position: DP, MSL, LLA */
- putb(1,0x02); /* Velocity: ENU */
- putb(2,0x00); /* Time: GPS */
- putb(3,0x08); /* Aux: dBHz */
+ putbyte(0,0x1e); /* Position: DP, MSL, LLA */
+ putbyte(1,0x02); /* Velocity: ENU */
+ putbyte(2,0x00); /* Time: GPS */
+ putbyte(3,0x08); /* Aux: dBHz */
(void)tsip_write(session->gpsdata.gps_fd, 0x35, buf, 4);
/* Request Software Versions */
@@ -94,16 +97,16 @@ static bool tsip_speed_switch(struct gps_device_t *session, unsigned int speed)
{
unsigned char buf[100];
- putb(0,0xff); /* current port */
- putb(1,(round(log(speed/300)/M_LN2))+2); /* input baudrate */
- putb(2,buf[1]); /* output baudrate */
- putb(3,8); /* character width (8 bits) */
- putb(4,1); /* parity (odd) */
- putb(5,0); /* stop bits (1 stopbit) */
- putb(6,0); /* flow control (none) */
- putb(7,0x02); /* input protocol (TSIP) */
- putb(8,0x02); /* input protocol (TSIP) */
- putb(9,0); /* reserved */
+ putbyte(0,0xff); /* current port */
+ putbyte(1,(round(log((double)speed/300)/M_LN2))+2); /* input baudrate */
+ putbyte(2,buf[1]); /* output baudrate */
+ putbyte(3,8); /* character width (8 bits) */
+ putbyte(4,1); /* parity (odd) */
+ putbyte(5,0); /* stop bits (1 stopbit) */
+ putbyte(6,0); /* flow control (none) */
+ putbyte(7,0x02); /* input protocol (TSIP) */
+ putbyte(8,0x02); /* input protocol (TSIP) */
+ putbyte(9,0); /* reserved */
(void)tsip_write(session->gpsdata.gps_fd, 0xbc, buf, 10);
return true; /* it would be nice to error-check this */
@@ -127,13 +130,14 @@ static int tsip_analyze(struct gps_device_t *session)
return 0;
}
+ /*@ +charint @*/
if (session->outbuflen < 4 || session->outbuffer[0] != 0x10)
return 0;
/* remove DLE stuffing and put data part of message in buf */
buf2[0] = '\0';
- for (i = 2; i < session->outbuflen; i++) {
+ for (i = 2; i < (int)session->outbuflen; i++) {
if (session->outbuffer[i] == 0x10)
if (session->outbuffer[++i] == 0x03)
break;
@@ -142,6 +146,7 @@ static int tsip_analyze(struct gps_device_t *session)
sizeof(buf)-strlen(buf),
"%02x", buf[len++] = session->outbuffer[i]);
}
+ /*@ -charint @*/
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
"ID%02x", id = session->outbuffer[1]);
@@ -151,13 +156,13 @@ static int tsip_analyze(struct gps_device_t *session)
switch (id) {
case 0x13: /* Packet Received */
gpsd_report(4, "Received packet of type %02x cannot be parsed\n",
- getb(0));
+ getbyte(0));
break;
case 0x41: /* GPS Time */
if (len != 10)
break;
f1 = getf(0); /* gpstime */
- s1 = getw(4); /* week */
+ s1 = getword(4); /* week */
f2 = getf(6); /* leap seconds */
if (f2 > 10.0) {
session->gps_week = s1;
@@ -167,7 +172,7 @@ static int tsip_analyze(struct gps_device_t *session)
session->gpsdata.sentence_time = gpstime_to_unix(s1, f1) - f2;
#ifdef NTPSHM_ENABLE
- ntpshm_put(session, session->gpsdata.sentence_time + 0.075);
+ (void)ntpshm_put(session, session->gpsdata.sentence_time + 0.075);
#endif
mask |= TIME_SET;
}
@@ -195,23 +200,23 @@ static int tsip_analyze(struct gps_device_t *session)
if (len != 10)
break;
gpsd_report(4, "Software versions %d.%d %02d%02d%02d %d.%d %02d%02d%02d\n",
- (int)getb(0),(int)getb(1),(int)getb(4),(int)getb(2),(int)getb(3),
- (int)getb(5),(int)getb(6),(int)getb(9),(int)getb(7),(int)getb(8));
+ (int)getbyte(0),(int)getbyte(1),(int)getbyte(4),(int)getbyte(2),(int)getbyte(3),
+ (int)getbyte(5),(int)getbyte(6),(int)getbyte(9),(int)getbyte(7),(int)getbyte(8));
break;
case 0x46: /* Health of Receiver */
if (len != 2)
break;
- gpsd_report(4, "Receiver health %02x %02x\n",getb(0),getb(1));
+ gpsd_report(4, "Receiver health %02x %02x\n",getbyte(0),getbyte(1));
break;
case 0x47: /* Signal Levels for all Satellites */
- s1 = getb(0); /* count */
+ s1 = getbyte(0); /* count */
if (len != (5*s1 + 1))
break;
gpsd_zero_satellites(&session->gpsdata);
session->gpsdata.satellites = s1;
buf2[0] = '\0';
for (i = 0; i < s1; i++) {
- session->gpsdata.PRN[i] = s2 = getb(5*i + 1);
+ session->gpsdata.PRN[i] = s2 = getbyte(5*i + 1);
session->gpsdata.ss[i] = f1 = getf(5*i + 2);
(void)snprintf(buf2+strlen(buf2), sizeof(buf2)-strlen(buf2),
" %d=%.1f",s2,f1);
@@ -243,12 +248,12 @@ static int tsip_analyze(struct gps_device_t *session)
case 0x4b: /* Machine/Code ID and Additional Status */
if (len != 3)
break;
- gpsd_report(4, "Machine ID %02x %02x %02x\n",getb(0),getb(1),getb(2));
+ gpsd_report(4, "Machine ID %02x %02x %02x\n",getbyte(0),getbyte(1),getbyte(2));
break;
case 0x55: /* IO Options */
if (len != 4)
break;
- gpsd_report(4, "IO Options %02x %02x %02x %02x\n",getb(0),getb(1),getb(2),getb(4));
+ gpsd_report(4, "IO Options %02x %02x %02x %02x\n",getbyte(0),getbyte(1),getbyte(2),getbyte(4));
break;
case 0x56: /* Velocity Fix, East-North-Up (ENU) */
if (len != 20)
@@ -271,10 +276,10 @@ static int tsip_analyze(struct gps_device_t *session)
if (len != 8)
break;
f1 = getf(2); /* gps_time */
- s1 = getw(6); /* gps_weeks */
- if (getb(0) != 0) /* good current fix? */
+ s1 = getword(6); /* gps_weeks */
+ if (getbyte(0) != 0) /* good current fix? */
session->gps_week = s1;
- gpsd_report(4, "Fix info %02x %02x %d %f\n",getb(0),getb(1),s1,f1);
+ gpsd_report(4, "Fix info %02x %02x %d %f\n",getbyte(0),getbyte(1),s1,f1);
break;
case 0x58: /* Satellite System Data/Acknowledge from Receiver */
break;
@@ -285,7 +290,7 @@ static int tsip_analyze(struct gps_device_t *session)
case 0x5c: /* Satellite Tracking Status */
break;
case 0x6d: /* All-In-View Satellite Selection */
- s1 = getb(0);
+ s1 = getbyte(0);
switch (s1 & 7) /* dimension */
{
case 3:
@@ -307,7 +312,7 @@ static int tsip_analyze(struct gps_device_t *session)
memset(session->gpsdata.used,0,sizeof(session->gpsdata.used));
for (i = 0; i < session->gpsdata.satellites_used; i++)
- session->gpsdata.used[i] = getb(16 + i);
+ session->gpsdata.used[i] = getbyte(16 + i);
gpsd_report(4, "Sat info: %d %d\n",session->gpsdata.fix.mode,session->gpsdata.satellites_used);
gpsd_binary_quality_dump(session, buf2, sizeof(buf2));
@@ -317,10 +322,10 @@ static int tsip_analyze(struct gps_device_t *session)
case 0x6e: /* Synchronized Measurements */
break;
case 0x6f: /* Synchronized Measurements Report */
- if (len < 20 || getb(0) != 1 || getb(1) != 2)
+ if (len < 20 || getbyte(0) != 1 || getbyte(1) != 2)
break;
- s1 = getw(2); /* number of bytes */
- s2 = getb(20); /* number of SVs */
+ s1 = getword(2); /* number of bytes */
+ s2 = getbyte(20); /* number of SVs */
break;
case 0x70: /* Filter Report */
break;
@@ -329,9 +334,9 @@ static int tsip_analyze(struct gps_device_t *session)
case 0x82: /* Differential Position Fix Mode */
if (len != 1)
break;
- if (session->gpsdata.status == STATUS_FIX && (getb(0) & 0x01))
+ if (session->gpsdata.status == STATUS_FIX && (getbyte(0) & 0x01))
session->gpsdata.status = STATUS_DGPS_FIX;
- gpsd_report(4, "DGPS mode %d\n",getb(0));
+ gpsd_report(4, "DGPS mode %d\n",getbyte(0));
break;
case 0x83: /* Double-Precision XYZ Position Fix and Bias Information */
if (len != 36)
@@ -361,7 +366,7 @@ static int tsip_analyze(struct gps_device_t *session)
mask |= LATLON_SET | ALTITUDE_SET;
break;
case 0x8f: /* Super Packet. Well... */
- switch (getb(0)) /* sub-packet ID */
+ switch (getbyte(0)) /* sub-packet ID */
{
case 0x20: /* Last Fix with Extra Information (binary fixed point) */
if (len != 56)
@@ -372,7 +377,7 @@ static int tsip_analyze(struct gps_device_t *session)
break;
break;
default:
- gpsd_report(4,"Unhandled TSIP superpacket type 0x%02x\n",getb(0));
+ gpsd_report(4,"Unhandled TSIP superpacket type 0x%02x\n",getbyte(0));
}
break;
default:
@@ -383,7 +388,7 @@ static int tsip_analyze(struct gps_device_t *session)
/* see if it is time to send some request packets for reports that */
/* the receiver won't send at fixed intervals */
- time(&t);
+ (void)time(&t);
if ((t - session->last_request) >= 5) {
/* Request GPS Receiver Position Fix Mode */
(void)tsip_write(session->gpsdata.gps_fd, 0x24, buf, 0);
diff --git a/zodiac.c b/zodiac.c
index 75c86cfd..35b6fc0c 100644
--- a/zodiac.c
+++ b/zodiac.c
@@ -78,7 +78,7 @@ static void zodiac_spew(struct gps_device_t *session, int type, unsigned short *
gpsd_report(5, "Sent Zodiac packet: %s\n",buf);
}
-static bool zodiac_speed_switch(struct gps_device_t *session, speed_t speed)
+static bool zodiac_speed_switch(struct gps_device_t *session, unsigned int speed)
{
unsigned short data[15];
@@ -92,7 +92,7 @@ static bool zodiac_speed_switch(struct gps_device_t *session, speed_t speed)
data[2] = 1; /* port 1 character width (8 bits) */
data[3] = 0; /* port 1 stop bits (1 stopbit) */
data[4] = 0; /* port 1 parity (none) */
- data[5] = (short)(round(log(speed/300)/M_LN2))+1; /* port 1 speed */
+ data[5] = (unsigned short)(round(log((double)speed/300)/M_LN2)+1); /* port 1 speed */
data[14] = zodiac_checksum(data, 14);
zodiac_spew(session, 1330, data, 15);
@@ -104,7 +104,7 @@ static void send_rtcm(struct gps_device_t *session,
char *rtcmbuf, size_t rtcmbytes)
{
unsigned short data[34];
- int n = 1 + (rtcmbytes/2 + rtcmbytes%2);
+ int n = 1 + (int)(rtcmbytes/2 + rtcmbytes%2);
if (session->sn++ > 32767)
session->sn = 0;
@@ -120,10 +120,10 @@ static void send_rtcm(struct gps_device_t *session,
static size_t zodiac_send_rtcm(struct gps_device_t *session,
char *rtcmbuf, size_t rtcmbytes)
{
- int len;
+ size_t len;
while (rtcmbytes > 0) {
- len = rtcmbytes>64?64:rtcmbytes;
+ len = (size_t)(rtcmbytes>64?64:rtcmbytes);
send_rtcm(session, rtcmbuf, len);
rtcmbytes -= len;
rtcmbuf += len;
@@ -132,82 +132,86 @@ static size_t zodiac_send_rtcm(struct gps_device_t *session,
}
/* Zodiac protocol description uses 1-origin indexing by little-endian word */
-#define getw(n) ( (session->outbuffer[2*(n)-2]) \
+#define getword(n) ( (session->outbuffer[2*(n)-2]) \
| (session->outbuffer[2*(n)-1] << 8))
-#define getl(n) ( (session->outbuffer[2*(n)-2]) \
+#define getlong(n) ( (session->outbuffer[2*(n)-2]) \
| (session->outbuffer[2*(n)-1] << 8) \
| (session->outbuffer[2*(n)+0] << 16) \
| (session->outbuffer[2*(n)+1] << 24))
static int handle1000(struct gps_device_t *session)
{
- /* ticks = getl(6); */
- /* sequence = getw(8); */
- /* measurement_sequence = getw(9); */
- session->gpsdata.status = (getw(10) & 0x1c) ? 0 : 1;
+ /* ticks = getlong(6); */
+ /* sequence = getword(8); */
+ /* measurement_sequence = getword(9); */
+ /*@ -boolops -predboolothers @*/
+ session->gpsdata.status = (getword(10) & 0x1c) ? 0 : 1;
if (session->gpsdata.status != 0)
- session->gpsdata.fix.mode = (getw(10) & 1) ? MODE_2D : MODE_3D;
+ session->gpsdata.fix.mode = (getword(10) & 1) ? MODE_2D : MODE_3D;
else
session->gpsdata.fix.mode = MODE_NO_FIX;
-
- /* solution_type = getw(11); */
- session->gpsdata.satellites_used = (int)getw(12);
- /* polar_navigation = getw(13); */
- /* gps_week = getw(14); */
- /* gps_seconds = getl(15); */
- /* gps_nanoseconds = getl(17); */
- session->gpsdata.nmea_date.tm_mday = (int)getw(19);
- session->gpsdata.nmea_date.tm_mon = (int)getw(20) - 1;
- session->gpsdata.nmea_date.tm_year = (int)getw(21) - 1900;
- session->gpsdata.nmea_date.tm_hour = (int)getw(22);
- session->gpsdata.nmea_date.tm_min = (int)getw(23);
- session->gpsdata.nmea_date.tm_sec = (int)getw(24);
- session->gpsdata.subseconds = getl(25) / 1e9;
+ /*@ +boolops -predboolothers @*/
+
+ /* solution_type = getword(11); */
+ session->gpsdata.satellites_used = (int)getword(12);
+ /* polar_navigation = getword(13); */
+ /* gps_week = getword(14); */
+ /* gps_seconds = getlong(15); */
+ /* gps_nanoseconds = getlong(17); */
+ session->gpsdata.nmea_date.tm_mday = (int)getword(19);
+ session->gpsdata.nmea_date.tm_mon = (int)getword(20) - 1;
+ session->gpsdata.nmea_date.tm_year = (int)getword(21) - 1900;
+ session->gpsdata.nmea_date.tm_hour = (int)getword(22);
+ session->gpsdata.nmea_date.tm_min = (int)getword(23);
+ session->gpsdata.nmea_date.tm_sec = (int)getword(24);
+ session->gpsdata.subseconds = (int)getlong(25) / 1e9;
session->gpsdata.fix.time = session->gpsdata.sentence_time =
(double)mkgmtime(&session->gpsdata.nmea_date) + session->gpsdata.subseconds;
#ifdef NTPSHM_ENABLE
if (session->gpsdata.fix.mode > MODE_NO_FIX)
(void)ntpshm_put(session, session->gpsdata.fix.time + 1.1);
#endif
- session->gpsdata.fix.latitude = ((long)getl(27)) * RAD_2_DEG * 1e-8;
- session->gpsdata.fix.longitude = ((long)getl(29)) * RAD_2_DEG * 1e-8;
- session->gpsdata.fix.altitude = ((long)getl(31)) * 1e-2;
- session->gpsdata.fix.separation = ((short)getw(33)) * 1e-2;
- session->gpsdata.fix.speed = getl(34) * 1e-2;
- session->gpsdata.fix.track = getw(36) * RAD_2_DEG * 1e-3;
- session->mag_var = ((short)getw(37)) * RAD_2_DEG * 1e-4;
- session->gpsdata.fix.climb = ((short)getw(38)) * 1e-2;
- /* map_datum = getw(39); */
- session->gpsdata.fix.eph = getl(40) * 1e-2;
- session->gpsdata.fix.epv = getl(42) * 1e-2;
- session->gpsdata.fix.ept = getl(44) * 1e-2;
- session->gpsdata.fix.eps = getw(46) * 1e-2;
- /* clock_bias = getl(47) * 1e-2; */
- /* clock_bias_sd = getl(49) * 1e-2; */
- /* clock_drift = getl(51) * 1e-2; */
- /* clock_drift_sd = getl(53) * 1e-2; */
+ /*@ -type @*/
+ session->gpsdata.fix.latitude = ((long)getlong(27)) * RAD_2_DEG * 1e-8;
+ session->gpsdata.fix.longitude = ((long)getlong(29)) * RAD_2_DEG * 1e-8;
+ session->gpsdata.fix.altitude = ((long)getlong(31)) * 1e-2;
+ /*@ +type @*/
+ session->gpsdata.fix.separation = ((short)getword(33)) * 1e-2;
+ session->gpsdata.fix.speed = (int)getlong(34) * 1e-2;
+ session->gpsdata.fix.track = (int)getword(36) * RAD_2_DEG * 1e-3;
+ session->mag_var = ((short)getword(37)) * RAD_2_DEG * 1e-4;
+ session->gpsdata.fix.climb = ((short)getword(38)) * 1e-2;
+ /* map_datum = getword(39); */
+ session->gpsdata.fix.eph = (int)getlong(40) * 1e-2;
+ session->gpsdata.fix.epv = (int)getlong(42) * 1e-2;
+ session->gpsdata.fix.ept = (int)getlong(44) * 1e-2;
+ session->gpsdata.fix.eps = (int)getword(46) * 1e-2;
+ /* clock_bias = (int)getlong(47) * 1e-2; */
+ /* clock_bias_sd = (int)getlong(49) * 1e-2; */
+ /* clock_drift = (int)getlong(51) * 1e-2; */
+ /* clock_drift_sd = (int)getlong(53) * 1e-2; */
#if 0
gpsd_report(1, "date: %lf\n", session->gpsdata.fix.time);
gpsd_report(1, " solution invalid:\n");
- gpsd_report(1, " altitude: %d\n", (getw(10) & 1) ? 1 : 0);
- gpsd_report(1, " no diff gps: %d\n", (getw(10) & 2) ? 1 : 0);
- gpsd_report(1, " not enough satellites: %d\n", (getw(10) & 4) ? 1 : 0);
- gpsd_report(1, " exceed max EHPE: %d\n", (getw(10) & 8) ? 1 : 0);
- gpsd_report(1, " exceed max EVPE: %d\n", (getw(10) & 16) ? 1 : 0);
+ gpsd_report(1, " altitude: %d\n", (getword(10) & 1) ? 1 : 0);
+ gpsd_report(1, " no diff gps: %d\n", (getword(10) & 2) ? 1 : 0);
+ gpsd_report(1, " not enough satellites: %d\n", (getword(10) & 4) ? 1 : 0);
+ gpsd_report(1, " exceed max EHPE: %d\n", (getword(10) & 8) ? 1 : 0);
+ gpsd_report(1, " exceed max EVPE: %d\n", (getword(10) & 16) ? 1 : 0);
gpsd_report(1, " solution type:\n");
- gpsd_report(1, " propagated: %d\n", (getw(11) & 1) ? 1 : 0);
- gpsd_report(1, " altitude: %d\n", (getw(11) & 2) ? 1 : 0);
- gpsd_report(1, " differential: %d\n", (getw(11) & 4) ? 1 : 0);
- gpsd_report(1, "Number of measurements in solution: %d\n", getw(12));
- gpsd_report(1, "Lat: %f\n", getl(27) * RAD_2_DEG * 1e-8);
- gpsd_report(1, "Lon: %f\n", getl(29) * RAD_2_DEG * 1e-8);
- gpsd_report(1, "Alt: %f\n", (double) getl(31) * 1e-2);
- gpsd_report(1, "Speed: %f\n", (double) getl(34) * 1e-2 * MPS_TO_KNOTS);
- gpsd_report(1, "Map datum: %d\n", getw(39));
- gpsd_report(1, "Magnetic variation: %f\n", getw(37) * RAD_2_DEG * 1e-4);
- gpsd_report(1, "Course: %f\n", getw(36) * RAD_2_DEG * 1e-4);
- gpsd_report(1, "Separation: %f\n", getw(33) * 1e-2);
+ gpsd_report(1, " propagated: %d\n", (getword(11) & 1) ? 1 : 0);
+ gpsd_report(1, " altitude: %d\n", (getword(11) & 2) ? 1 : 0);
+ gpsd_report(1, " differential: %d\n", (getword(11) & 4) ? 1 : 0);
+ gpsd_report(1, "Number of measurements in solution: %d\n", getword(12));
+ gpsd_report(1, "Lat: %f\n", getlong(27) * RAD_2_DEG * 1e-8);
+ gpsd_report(1, "Lon: %f\n", getlong(29) * RAD_2_DEG * 1e-8);
+ gpsd_report(1, "Alt: %f\n", (double) getlong(31) * 1e-2);
+ gpsd_report(1, "Speed: %f\n", (double) getlong(34) * 1e-2 * MPS_TO_KNOTS);
+ gpsd_report(1, "Map datum: %d\n", getword(39));
+ gpsd_report(1, "Magnetic variation: %f\n", getword(37) * RAD_2_DEG * 1e-4);
+ gpsd_report(1, "Course: %f\n", getword(36) * RAD_2_DEG * 1e-4);
+ gpsd_report(1, "Separation: %f\n", getword(33) * 1e-2);
#endif
session->gpsdata.sentence_length = 55;
@@ -220,15 +224,17 @@ static int handle1002(struct gps_device_t *session)
session->gpsdata.satellites_used = 0;
memset(session->gpsdata.used,0,sizeof(session->gpsdata.used));
- /* ticks = getl(6); */
- /* sequence = getw(8); */
- /* measurement_sequence = getw(9); */
- /* gps_week = getw(10); */
- /* gps_seconds = getl(11); */
- /* gps_nanoseconds = getl(13); */
+ /* ticks = getlong(6); */
+ /* sequence = getword(8); */
+ /* measurement_sequence = getword(9); */
+ /* gps_week = getword(10); */
+ /* gps_seconds = getlong(11); */
+ /* gps_nanoseconds = getlong(13); */
for (i = 0; i < MAXCHANNELS; i++) {
- session->Zv[i] = status = getw(15 + (3 * i));
- session->Zs[i] = prn = getw(16 + (3 * i));
+ /*@ -type @*/
+ session->Zv[i] = status = (int)getword(15 + (3 * i));
+ session->Zs[i] = prn = (int)getword(16 + (3 * i));
+ /*@ +type @*/
#if 0
gpsd_report(1, "Sat%02d:\n", i);
gpsd_report(1, " used:%d\n", (status & 1) ? 1 : 0);
@@ -236,14 +242,14 @@ static int handle1002(struct gps_device_t *session)
gpsd_report(1, " val:%d\n", (status & 4) ? 1 : 0);
gpsd_report(1, " dgps:%d\n", (status & 8) ? 1 : 0);
gpsd_report(1, " PRN:%d\n", prn);
- gpsd_report(1, " C/No:%d\n", getw(17 + (3 * i)));
+ gpsd_report(1, " C/No:%d\n", getword(17 + (3 * i)));
#endif
if (status & 1)
session->gpsdata.used[session->gpsdata.satellites_used++] = prn;
for (j = 0; j < MAXCHANNELS; j++) {
if (session->gpsdata.PRN[j] != prn)
continue;
- session->gpsdata.ss[j] = getw(17 + (3 * i));
+ session->gpsdata.ss[j] = (int)getword(17 + (3 * i));
break;
}
}
@@ -254,25 +260,25 @@ static int handle1003(struct gps_device_t *session)
{
int i;
- /* ticks = getl(6); */
- /* sequence = getw(8); */
- session->gpsdata.gdop = getw(9) * 1e-2;
- session->gpsdata.pdop = getw(10) * 1e-2;
- session->gpsdata.hdop = getw(11) * 1e-2;
- session->gpsdata.vdop = getw(12) * 1e-2;
- session->gpsdata.tdop = getw(13) * 1e-2;
- session->gpsdata.satellites = getw(14);
+ /* ticks = getlong(6); */
+ /* sequence = getword(8); */
+ session->gpsdata.gdop = (unsigned int)getword(9) * 1e-2;
+ session->gpsdata.pdop = (unsigned int)getword(10) * 1e-2;
+ session->gpsdata.hdop = (unsigned int)getword(11) * 1e-2;
+ session->gpsdata.vdop = (unsigned int)getword(12) * 1e-2;
+ session->gpsdata.tdop = (unsigned int)getword(13) * 1e-2;
+ session->gpsdata.satellites = (int)getword(14);
for (i = 0; i < MAXCHANNELS; i++) {
if (i < session->gpsdata.satellites) {
- session->gpsdata.PRN[i] = getw(15 + (3 * i));
- session->gpsdata.azimuth[i] = ((short)getw(16 + (3 * i))) * RAD_2_DEG * 1e-4;
+ session->gpsdata.PRN[i] = (int)getword(15 + (3 * i));
+ session->gpsdata.azimuth[i] = (int)(((short)getword(16 + (3 * i))) * RAD_2_DEG * 1e-4);
if (session->gpsdata.azimuth[i] < 0)
session->gpsdata.azimuth[i] += 360;
- session->gpsdata.elevation[i] = ((short)getw(17 + (3 * i))) * RAD_2_DEG * 1e-4;
+ session->gpsdata.elevation[i] = (int)(((short)getword(17 + (3 * i))) * RAD_2_DEG * 1e-4);
#if 0
gpsd_report(1, "Sat%02d: PRN:%d az:%d el:%d\n",
- i, getw(15+(3 * i)),getw(16+(3 * i)),getw(17+(3 * i)));
+ i, getword(15+(3 * i)),getword(16+(3 * i)),getword(17+(3 * i)));
#endif
} else {
session->gpsdata.PRN[i] = 0;
@@ -285,41 +291,41 @@ static int handle1003(struct gps_device_t *session)
static void handle1005(struct gps_device_t *session UNUSED)
{
- /* ticks = getl(6); */
- /* sequence = getw(8); */
+ /* ticks = getlong(6); */
+ /* sequence = getword(8); */
#if 0
- int i, numcorrections = getw(12);
+ int i, numcorrections = getword(12);
gpsd_report(1, "Packet: %d\n", session->sn);
- gpsd_report(1, "Station bad: %d\n", (getw(9) & 1) ? 1 : 0);
- gpsd_report(1, "User disabled: %d\n", (getw(9) & 2) ? 1 : 0);
- gpsd_report(1, "Station ID: %d\n", getw(10));
- gpsd_report(1, "Age of last correction in seconds: %d\n", getw(11));
- gpsd_report(1, "Number of corrections: %d\n", getw(12));
+ gpsd_report(1, "Station bad: %d\n", (getword(9) & 1) ? 1 : 0);
+ gpsd_report(1, "User disabled: %d\n", (getword(9) & 2) ? 1 : 0);
+ gpsd_report(1, "Station ID: %d\n", getword(10));
+ gpsd_report(1, "Age of last correction in seconds: %d\n", getword(11));
+ gpsd_report(1, "Number of corrections: %d\n", getword(12));
for (i = 0; i < numcorrections; i++) {
- gpsd_report(1, "Sat%02d:\n", getw(13+i) & 0x3f);
- gpsd_report(1, "ephemeris:%d\n", (getw(13+i) & 64) ? 1 : 0);
- gpsd_report(1, "rtcm corrections:%d\n", (getw(13+i) & 128) ? 1 : 0);
- gpsd_report(1, "rtcm udre:%d\n", (getw(13+i) & 256) ? 1 : 0);
- gpsd_report(1, "sat health:%d\n", (getw(13+i) & 512) ? 1 : 0);
- gpsd_report(1, "rtcm sat health:%d\n", (getw(13+i) & 1024) ? 1 : 0);
- gpsd_report(1, "corrections state:%d\n", (getw(13+i) & 2048) ? 1 : 0);
- gpsd_report(1, "iode mismatch:%d\n", (getw(13+i) & 4096) ? 1 : 0);
+ gpsd_report(1, "Sat%02d:\n", getword(13+i) & 0x3f);
+ gpsd_report(1, "ephemeris:%d\n", (getword(13+i) & 64) ? 1 : 0);
+ gpsd_report(1, "rtcm corrections:%d\n", (getword(13+i) & 128) ? 1 : 0);
+ gpsd_report(1, "rtcm udre:%d\n", (getword(13+i) & 256) ? 1 : 0);
+ gpsd_report(1, "sat health:%d\n", (getword(13+i) & 512) ? 1 : 0);
+ gpsd_report(1, "rtcm sat health:%d\n", (getword(13+i) & 1024) ? 1 : 0);
+ gpsd_report(1, "corrections state:%d\n", (getword(13+i) & 2048) ? 1 : 0);
+ gpsd_report(1, "iode mismatch:%d\n", (getword(13+i) & 4096) ? 1 : 0);
}
#endif
}
static void handle1108(struct gps_device_t *session)
{
- /* ticks = getl(6); */
- /* sequence = getw(8); */
- /* utc_week_seconds = getl(14); */
- /* leap_nanoseconds = getl(17); */
- if ((getw(19) & 3) == 3)
- session->context->leap_seconds = getw(16);
+ /* ticks = getlong(6); */
+ /* sequence = getword(8); */
+ /* utc_week_seconds = getlong(14); */
+ /* leap_nanoseconds = getlong(17); */
+ if ((int)(getword(19) & 3) == 3)
+ session->context->leap_seconds = (int)getword(16);
#if 0
- gpsd_report(1, "Leap seconds: %d.%09d\n", getw(16), getl(17));
- gpsd_report(1, "UTC validity: %d\n", getw(19) & 3);
+ gpsd_report(1, "Leap seconds: %d.%09d\n", getword(16), getlong(17));
+ gpsd_report(1, "UTC validity: %d\n", getword(19) & 3);
#endif
}
@@ -327,7 +333,7 @@ static int zodiac_analyze(struct gps_device_t *session)
{
char buf[BUFSIZ];
int i, mask = 0;
- unsigned int id = (session->outbuffer[3] << 8) | session->outbuffer[2];
+ unsigned int id = (unsigned int)((session->outbuffer[3]<<8) | session->outbuffer[2]);
if (session->packet_type != ZODIAC_PACKET) {
gpsd_report(2, "zodiac_analyze packet type %d\n",session->packet_type);
@@ -335,9 +341,9 @@ static int zodiac_analyze(struct gps_device_t *session)
}
buf[0] = '\0';
- for (i = 0; i < session->outbuflen; i++)
+ for (i = 0; i < (int)session->outbuflen; i++)
(void)snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf),
- "%02x", session->outbuffer[i]);
+ "%02x", (unsigned int)session->outbuffer[i]);
(void)strcat(buf, "\n");
gpsd_report(5, "Raw Zodiac packet type %d length %d: %s\n",id,session->outbuflen,buf);
@@ -356,7 +362,7 @@ static int zodiac_analyze(struct gps_device_t *session)
mask = handle1002(session);
strcpy(buf, "$PRWIZCH");
for (i = 0; i < MAXCHANNELS; i++) {
- (void)snprintf(buf+strlen(buf), (int)(sizeof(buf)-strlen(buf)),
+ (void)snprintf(buf+strlen(buf), (size_t)(sizeof(buf)-strlen(buf)),
",%02u,%X", session->Zs[i], session->Zv[i] & 0x0f);
}
(void)strcat(buf, "*");
@@ -369,7 +375,7 @@ static int zodiac_analyze(struct gps_device_t *session)
break;
case 1003:
mask = handle1003(session);
- gpsd_binary_satellite_dump(session, buf, sizeof(buf));
+ gpsd_binary_satellite_dump(session, buf, (int)sizeof(buf));
gpsd_report(3, "<= GPS: %s", buf);
break;
case 1005: