summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--garmin.c6
-rw-r--r--gpsd.c2
-rw-r--r--gpsd.h20
-rw-r--r--gpsutils.c2
-rw-r--r--isgps.c43
-rw-r--r--rtcm.c7
-rw-r--r--rtcmdecode.c6
7 files changed, 46 insertions, 40 deletions
diff --git a/garmin.c b/garmin.c
index 830095d9..e89a5617 100644
--- a/garmin.c
+++ b/garmin.c
@@ -207,6 +207,7 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt );
static void SendPacket (struct gps_device_t *session, Packet_t *aPacket );
static int GetPacket (struct gps_device_t *session );
+/*@ -branchstate @*/
// For debugging, decodes and prints some known packets.
static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt)
{
@@ -273,7 +274,7 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt)
msg = "Start RMD data";
break;
default:
- sprintf( buf, "Unknown: %d", prod_id);
+ (void)snprintf(buf, sizeof(buf), "Unknown: %u", prod_id);
msg = buf;
break;
}
@@ -461,7 +462,7 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt)
// private
switch( pkt->mPacketId ) {
case PRIV_PKTID_SET_MODE:
- prod_id = get_int(&pkt->mData.uchars[0]);
+ prod_id = (unsigned short)get_int(&pkt->mData.uchars[0]);
gpsd_report(3, "Private, Set Mode: %d\n", prod_id);
break;
case PRIV_PKTID_INFO_REQ:
@@ -496,6 +497,7 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt)
return mask;
}
+/*@ +branchstate @*/
//-----------------------------------------------------------------------------
// send a packet in GarminUSB format
diff --git a/gpsd.c b/gpsd.c
index 6aedcffb..734efa28 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -541,7 +541,7 @@ static int handle_gpsd_request(int cfd, char *buf, int buflen)
if (whoami->device) {
if ( whoami->device->gpsdata.parity == 0 ) {
/* zero parity breaks the next snprintf */
- whoami->device->gpsdata.parity = 'N';
+ whoami->device->gpsdata.parity = (unsigned)'N';
}
(void)snprintf(phrase, sizeof(phrase), ",B=%d %d %c %u",
(int)gpsd_get_speed(&whoami->device->ttyset),
diff --git a/gpsd.h b/gpsd.h
index c77d1f57..ea4e8e3b 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -36,7 +36,7 @@ enum isgpsstat_t {
};
#define PREAMBLE_PATTERN 0x66
-#define RTCM_ERRLEVEL_BASE 5
+#define ISGPS_ERRLEVEL_BASE 5
#define NTPSHMSEGS 4 /* number of NTP SHM segments */
@@ -267,17 +267,18 @@ extern /*@ observer @*/ char *gpsd_hexdump(const void *, size_t);
extern int netlib_connectsock(const char *, const char *, const char *);
extern int ntpshm_init(struct gps_context_t *, bool);
-extern int ntpshm_alloc(struct gps_context_t *context);
-extern bool ntpshm_free(struct gps_context_t *context, int segment);
+extern int ntpshm_alloc(struct gps_context_t *);
+extern bool ntpshm_free(struct gps_context_t *, int);
extern int ntpshm_put(struct gps_device_t *, double);
extern int ntpshm_pps(struct gps_device_t *,struct timeval *);
extern void isgps_init(/*@out@*/struct gps_device_t *);
-enum isgpsstat_t isgps_decode(struct gps_device_t *session,
+enum isgpsstat_t isgps_decode(struct gps_device_t *,
bool (*preamble_match)(isgps30bits_t *),
bool (*length_check)(struct gps_device_t *),
- unsigned int c);
-extern unsigned int isgps_parity(isgps30bits_t th);
+ size_t,
+ unsigned int);
+extern unsigned int isgps_parity(isgps30bits_t);
extern enum isgpsstat_t rtcm_decode(struct gps_device_t *, unsigned int);
extern void rtcm_dump(struct gps_device_t *, /*@out@*/char[], size_t);
@@ -294,13 +295,12 @@ extern gps_mask_t dop(struct gps_data_t *);
extern void hexdump(size_t, unsigned char *, unsigned char *);
extern unsigned char sr_sum(unsigned int, unsigned int, unsigned char *);
extern int bin2srec(unsigned int, unsigned int, unsigned int, unsigned char *, unsigned char *);
-extern int srec_hdr(unsigned int num, unsigned char *bbuf, unsigned char *sbuf);
+extern int srec_hdr(unsigned int, unsigned char *, unsigned char *);
extern int srec_fin(unsigned int, unsigned char *);
extern unsigned char hc(unsigned char);
/* External interface */
-extern void gpsd_init(struct gps_device_t *,
- struct gps_context_t *, char *device);
+extern void gpsd_init(struct gps_device_t *, struct gps_context_t *, char *);
extern int gpsd_activate(struct gps_device_t *);
extern void gpsd_deactivate(struct gps_device_t *);
extern gps_mask_t gpsd_poll(struct gps_device_t *);
@@ -313,7 +313,7 @@ void gpsd_report(int, const char *, ...);
extern bool finite(double);
extern int cfmakeraw(struct termios *);
extern struct protoent *getprotobyname(const char *);
-extern /*@observer@*/char *strptime(const char *,const char *,/*@out@*/struct tm *tp)/*@modifies tp@*/;
+extern /*@observer@*/char *strptime(const char *,const char *tp,/*@out@*/struct tm *)/*@modifies tp@*/;
extern struct tm *gmtime_r(const time_t *,/*@out@*/struct tm *tp)/*@modifies tp@*/;
extern struct tm *localtime_r(const time_t *,/*@out@*/struct tm *tp)/*@modifies tp@*/;
extern float roundf(float x);
diff --git a/gpsutils.c b/gpsutils.c
index f05188b6..82bc8524 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -100,7 +100,7 @@ double iso8601_to_unix(/*@in@*/char *isotime)
double usec;
struct tm tm;
- dp = strptime(isotime, "%Y-%m-%dT%H:%M:%S", &tm);
+ /*@i1@*/dp = strptime(isotime, "%Y-%m-%dT%H:%M:%S", &tm);
if (*dp == '.')
usec = strtod(dp, NULL);
else
diff --git a/isgps.c b/isgps.c
index 63e08808..b0e39ef9 100644
--- a/isgps.c
+++ b/isgps.c
@@ -137,7 +137,7 @@ unsigned int isgps_parity(isgps30bits_t th)
parity_array[(t >> 16) & 0xff] ^ parity_array[(t >> 24) & 0xff]);
/*@ -charint @*/
- gpsd_report(RTCM_ERRLEVEL_BASE+2, "parity %u\n", p);
+ gpsd_report(ISGPS_ERRLEVEL_BASE+2, "ISGPS parity %u\n", p);
return (p);
}
@@ -182,14 +182,15 @@ void isgps_init(/*@out@*/struct gps_device_t *session)
enum isgpsstat_t isgps_decode(struct gps_device_t *session,
bool (*preamble_match)(isgps30bits_t *),
bool (*length_check)(struct gps_device_t *),
+ size_t maxlen,
unsigned int c)
{
enum isgpsstat_t res;
/* ASCII characters 64-127, @ through DEL */
if ((c & MAG_TAG_MASK) != MAG_TAG_DATA) {
- gpsd_report(RTCM_ERRLEVEL_BASE+1,
- "word tag not correct, skipping\n");
+ gpsd_report(ISGPS_ERRLEVEL_BASE+1,
+ "ISGPS word tag not correct, skipping\n");
return ISGPS_SKIP;
}
@@ -207,18 +208,18 @@ enum isgpsstat_t isgps_decode(struct gps_device_t *session,
} else {
session->driver.isgps.curr_word |= c >> -(session->driver.isgps.curr_offset);
}
- gpsd_report(RTCM_ERRLEVEL_BASE+2, "syncing at byte %d: %0x%08x\n", session->char_counter, session->driver.isgps.curr_word);
+ gpsd_report(ISGPS_ERRLEVEL_BASE+2, "ISGPS syncing at byte %d: %0x%08x\n", session->char_counter, session->driver.isgps.curr_word);
if (preamble_match(&session->driver.isgps.curr_word)) {
if (isgps_parityok(session->driver.isgps.curr_word)) {
- gpsd_report(RTCM_ERRLEVEL_BASE+1,
- "preamble ok, parity ok -- locked\n");
+ gpsd_report(ISGPS_ERRLEVEL_BASE+1,
+ "ISGPS preamble ok, parity ok -- locked\n");
session->driver.isgps.locked = true;
/* session->driver.isgps.curr_offset; XXX - testing */
break;
}
- gpsd_report(RTCM_ERRLEVEL_BASE+1,
- "preamble ok, parity fail\n");
+ gpsd_report(ISGPS_ERRLEVEL_BASE+1,
+ "ISGPS preamble ok, parity fail\n");
}
session->driver.isgps.curr_offset++;
} /* end while */
@@ -244,24 +245,24 @@ enum isgpsstat_t isgps_decode(struct gps_device_t *session,
* another preamble pattern in the data stream. -wsr
*/
if (preamble_match(&session->driver.isgps.curr_word)) {
- gpsd_report(RTCM_ERRLEVEL_BASE+2,
- "Preamble spotted (index: %u)\n",
+ gpsd_report(ISGPS_ERRLEVEL_BASE+2,
+ "ISGPS preamble spotted (index: %u)\n",
session->driver.isgps.bufindex);
session->driver.isgps.bufindex = 0;
}
#endif
- gpsd_report(RTCM_ERRLEVEL_BASE+2,
- "processing word %u (offset %d)\n",
+ gpsd_report(ISGPS_ERRLEVEL_BASE+2,
+ "ISGPS processing word %u (offset %d)\n",
session->driver.isgps.bufindex, session->driver.isgps.curr_offset);
{
/*
* Guard against a buffer overflow attack. Just wait for
* the next PREAMBLE_PATTERN and go on from there.
*/
- if (session->driver.isgps.bufindex >= RTCM_WORDS_MAX){
+ if (session->driver.isgps.bufindex >= (unsigned)maxlen){
session->driver.isgps.bufindex = 0;
- gpsd_report(RTCM_ERRLEVEL_BASE+1,
- "RTCM buffer overflowing -- resetting\n");
+ gpsd_report(ISGPS_ERRLEVEL_BASE+1,
+ "ISGPS buffer overflowing -- resetting\n");
return ISGPS_NO_SYNC;
}
@@ -269,8 +270,8 @@ enum isgpsstat_t isgps_decode(struct gps_device_t *session,
if ((session->driver.isgps.bufindex == 0) &&
!preamble_match((isgps30bits_t *)session->driver.isgps.buf)) {
- gpsd_report(RTCM_ERRLEVEL_BASE+1,
- "word 0 not a preamble- punting\n");
+ gpsd_report(ISGPS_ERRLEVEL_BASE+1,
+ "ISGPS word 0 not a preamble- punting\n");
return ISGPS_NO_SYNC;
}
session->driver.isgps.bufindex++;
@@ -289,19 +290,19 @@ enum isgpsstat_t isgps_decode(struct gps_device_t *session,
session->driver.isgps.curr_word |= c >> -(session->driver.isgps.curr_offset);
}
} else {
- gpsd_report(RTCM_ERRLEVEL_BASE+0,
- "parity failure, lost lock\n");
+ gpsd_report(ISGPS_ERRLEVEL_BASE+0,
+ "ISGPS parity failure, lost lock\n");
session->driver.isgps.locked = false;
}
}
session->driver.isgps.curr_offset -= 6;
- gpsd_report(RTCM_ERRLEVEL_BASE+2, "residual %d\n", session->driver.isgps.curr_offset);
+ gpsd_report(ISGPS_ERRLEVEL_BASE+2, "residual %d\n", session->driver.isgps.curr_offset);
return res;
}
/*@ +shiftnegative @*/
/* never achieved lock */
- gpsd_report(RTCM_ERRLEVEL_BASE+1,
+ gpsd_report(ISGPS_ERRLEVEL_BASE+1,
"lock never achieved\n");
return ISGPS_NO_SYNC;
}
diff --git a/rtcm.c b/rtcm.c
index aa333b2b..c7de0d47 100644
--- a/rtcm.c
+++ b/rtcm.c
@@ -871,8 +871,11 @@ static bool length_check(struct gps_device_t *session)
enum isgpsstat_t rtcm_decode(struct gps_device_t *session, unsigned int c)
{
- enum isgpsstat_t res = isgps_decode(session, preamble_match, length_check, c);
-
+ enum isgpsstat_t res = isgps_decode(session,
+ preamble_match,
+ length_check,
+ RTCM_WORDS_MAX,
+ c);
if (res == ISGPS_MESSAGE)
rtcm_unpack(session);
diff --git a/rtcmdecode.c b/rtcmdecode.c
index bc73aa28..9068981e 100644
--- a/rtcmdecode.c
+++ b/rtcmdecode.c
@@ -9,7 +9,7 @@
#include "gpsd.h"
-static int verbose = RTCM_ERRLEVEL_BASE;
+static int verbose = ISGPS_ERRLEVEL_BASE;
void gpsd_report(int errlevel, const char *fmt, ... )
/* assemble command in printf(3) style, use stderr or syslog */
@@ -41,7 +41,7 @@ static void decode(FILE *fpin, FILE *fpout)
count = 0;
while ((c = fgetc(fpin)) != EOF) {
res = rtcm_decode(&device, (unsigned int)c);
- if (verbose >= RTCM_ERRLEVEL_BASE + 3)
+ if (verbose >= ISGPS_ERRLEVEL_BASE + 3)
fprintf(fpout, "%08lu: '%c' [%02x] -> %d\n",
(unsigned long)count++, (isprint(c)?c:'.'), (unsigned)(c & 0xff), res);
if (res == ISGPS_MESSAGE) {
@@ -138,7 +138,7 @@ int main(int argc, char **argv)
break;
case 'v': /* verbose */
- verbose = RTCM_ERRLEVEL_BASE + atoi(optarg);
+ verbose = ISGPS_ERRLEVEL_BASE + atoi(optarg);
break;
case '?':