summaryrefslogtreecommitdiff
path: root/driver_superstar2.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-09-29 01:42:45 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-09-29 01:46:53 -0400
commit4361ec2d89bdf451602d659ddfd0fb9a79c178a2 (patch)
treeaf067d1d7614a9e67f449eec933ba3347cde10b0 /driver_superstar2.c
parenta77b95b57475c2856707e91b197f8aaa8e5eb407 (diff)
downloadgpsd-4361ec2d89bdf451602d659ddfd0fb9a79c178a2.tar.gz
Change gpsd_report to no longer use a global. All regression tests pass.
This is a large, ugly change. But without it we can't troubleshoot the ICP/IP-source initialization bug properly - colliding definitions of gpsd_report() were interfering with error reporting early in gpsd runs. More cleanup work remains to be done, but at least this is working.
Diffstat (limited to 'driver_superstar2.c')
-rw-r--r--driver_superstar2.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/driver_superstar2.c b/driver_superstar2.c
index b92340e2..64bbd97e 100644
--- a/driver_superstar2.c
+++ b/driver_superstar2.c
@@ -50,11 +50,11 @@ static void superstar2_set_mode(struct gps_device_t *, int);
* Decode the message ACK message
*/
static gps_mask_t
-superstar2_msg_ack(struct gps_device_t *session UNUSED,
+superstar2_msg_ack(struct gps_device_t *session,
unsigned char *buf, size_t data_len)
{
if (data_len == 11)
- gpsd_report(LOG_PROG,
+ gpsd_report(session->context->debug, LOG_PROG,
"superstar2 #126 - "
"ACK %d %d %d %d %d\n",
buf[5], buf[6], buf[7], buf[8], buf[9]);
@@ -80,7 +80,8 @@ superstar2_msg_navsol_lla(struct gps_device_t *session,
if (data_len != 77)
return 0;
- gpsd_report(LOG_PROG, "superstar2 #20 - user navigation data\n");
+ gpsd_report(session->context->debug, LOG_PROG,
+ "superstar2 #20 - user navigation data\n");
mask = 0;
/*@ +charint @*/
@@ -141,7 +142,7 @@ superstar2_msg_navsol_lla(struct gps_device_t *session,
}
mask |= MODE_SET | STATUS_SET;
- gpsd_report(LOG_DATA,
+ gpsd_report(session->context->debug, LOG_DATA,
"NAVSOL_LLA: time=%.2f lat=%.2f lon=%.2f alt=%.2f track=%.2f speed=%.2f climb=%.2f mode=%d status=%d hdop=%.2f hdop=%.2f used=%d\n",
session->newdata.time,
session->newdata.latitude,
@@ -170,7 +171,8 @@ superstar2_msg_svinfo(struct gps_device_t *session,
if (data_len != 67)
return 0;
- gpsd_report(LOG_PROG, "superstar2 #33 - satellite data\n");
+ gpsd_report(session->context->debug, LOG_PROG,
+ "superstar2 #33 - satellite data\n");
nchan = 12;
gpsd_zero_satellites(&session->gpsdata);
@@ -199,7 +201,7 @@ superstar2_msg_svinfo(struct gps_device_t *session,
session->gpsdata.skyview_time = NAN;
session->gpsdata.satellites_used = nsv;
session->gpsdata.satellites_visible = st;
- gpsd_report(LOG_DATA,
+ gpsd_report(session->context->debug, LOG_DATA,
"SVINFO: visible=%d used=%d mask={SATELLITE|USED}\n",
session->gpsdata.satellites_visible,
session->gpsdata.satellites_used);
@@ -224,12 +226,13 @@ superstar2_msg_version(struct gps_device_t *session,
(void)snprintf(boot_sw, 15, "%s", (char *)buf + 36);
(void)snprintf(ser_num, 14, "%s", (char *)buf + 73);
- gpsd_report(LOG_PROG,
+ gpsd_report(session->context->debug, LOG_PROG,
"superstar2 #45 - "
"hw part %s boot sw %s main sw %s ser num %s\n",
hw_part, boot_sw, main_sw, ser_num);
(void)strlcpy(session->subtype, main_sw, sizeof(session->subtype));
- gpsd_report(LOG_DATA, "VERSION: subtype='%s' mask={DEVEICEID}\n",
+ gpsd_report(session->context->debug, LOG_DATA,
+ "VERSION: subtype='%s' mask={DEVEICEID}\n",
session->subtype);
return DEVICEID_SET;
}
@@ -247,7 +250,8 @@ superstar2_msg_timing(struct gps_device_t *session, unsigned char *buf,
if (data_len != 65)
return 0;
- gpsd_report(LOG_PROG, "superstar2 #113 - timing status\n");
+ gpsd_report(session->context->debug, LOG_PROG,
+ "superstar2 #113 - timing status\n");
/*@ +charint @*/
if ((getub(buf, 55) & 0x30) != 0)
mask = 0;
@@ -268,7 +272,8 @@ superstar2_msg_timing(struct gps_device_t *session, unsigned char *buf,
session->context->leap_seconds = (int)getsb(buf, 20);
mask = TIME_SET | PPSTIME_IS;
}
- gpsd_report(LOG_DATA, "TIMING: time=%.2f mask={TIME}\n",
+ gpsd_report(session->context->debug, LOG_DATA,
+ "TIMING: time=%.2f mask={TIME}\n",
session->newdata.time);
return mask;
}
@@ -285,11 +290,13 @@ superstar2_msg_measurement(struct gps_device_t *session, unsigned char *buf,
unsigned long ul;
double t;
- gpsd_report(LOG_PROG, "superstar2 #23 - measurement block\n");
+ gpsd_report(session->context->debug, LOG_PROG,
+ "superstar2 #23 - measurement block\n");
n = (int)getub(buf, 6); /* number of measurements */
if ((n < 1) || (n > MAXCHANNELS)) {
- gpsd_report(LOG_INF, "too many measurements\n");
+ gpsd_report(session->context->debug, LOG_INF,
+ "too many measurements\n");
return 0;
}
t = getled64((char *)buf, 7); /* measurement time */
@@ -328,7 +335,7 @@ superstar2_msg_iono_utc(struct gps_device_t *session, unsigned char *buf,
i = (unsigned int)getub(buf, 12);
u = (unsigned int)getub(buf, 21);
- gpsd_report(LOG_PROG,
+ gpsd_report(session->context->debug, LOG_PROG,
"superstar2 #75 - ionospheric & utc data: iono %s utc %s\n",
i ? "ok" : "bad", u ? "ok" : "bad");
session->driver.superstar2.last_iono = time(NULL);
@@ -346,7 +353,8 @@ superstar2_msg_ephemeris(struct gps_device_t *session, unsigned char *buf,
{
unsigned int prn;
prn = (unsigned int)(getub(buf, 4) & 0x1f);
- gpsd_report(LOG_PROG, "superstar2 #22 - ephemeris data - prn %u\n", prn);
+ gpsd_report(session->context->debug, LOG_PROG,
+ "superstar2 #22 - ephemeris data - prn %u\n", prn);
/* ephemeris data updates fairly slowly, but when it does, poll UTC */
if ((time(NULL) - session->driver.superstar2.last_iono) > 60)
@@ -368,7 +376,8 @@ superstar2_write(struct gps_device_t *session, char *msg, size_t msglen)
c += 0x100;
msg[(int)msg[3] + 4] = (char)((c >> 8) & 0xff);
msg[(int)msg[3] + 5] = (char)(c & 0xff);
- gpsd_report(LOG_IO, "writing superstar2 control type %d len %zu\n",
+ gpsd_report(session->context->debug, LOG_IO,
+ "writing superstar2 control type %d len %zu\n",
(int)msg[1] & 0x7f, msglen);
return gpsd_write(session, msg, msglen);
}
@@ -411,7 +420,7 @@ superstar2_dispatch(struct gps_device_t * session, unsigned char *buf,
return superstar2_msg_ephemeris(session, buf, len);
default:
- gpsd_report(LOG_WARN,
+ gpsd_report(session->context->debug, LOG_WARN,
"unknown superstar2 packet id 0x%02x length %zd\n",
type, len);
return 0;