summaryrefslogtreecommitdiff
path: root/rtcmdecode.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-07-13 12:37:57 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-07-13 12:37:57 +0000
commit2ffc6d64dab03f8e71e6908901730f38f6ffdde9 (patch)
tree6e99e6eb45882d3b499ec2d353a4f6b751f82082 /rtcmdecode.c
parent7e302f275593f8a3d161eb5f0708f095b0199479 (diff)
downloadgpsd-2ffc6d64dab03f8e71e6908901730f38f6ffdde9.tar.gz
More refactoring, RTCM dump function is now an ordinary dump hook.
Diffstat (limited to 'rtcmdecode.c')
-rw-r--r--rtcmdecode.c68
1 files changed, 5 insertions, 63 deletions
diff --git a/rtcmdecode.c b/rtcmdecode.c
index 46a89423..59e933b9 100644
--- a/rtcmdecode.c
+++ b/rtcmdecode.c
@@ -25,72 +25,12 @@ void gpsd_report(int errlevel, const char *fmt, ... )
}
}
-void rtcm_print_msg(struct rtcm_msghdr *msghdr)
-/* dump the contents of a parsed RTCM104 message */
-{
- int len = (int)msghdr->w2.frmlen;
- double zcount = msghdr->w2.zcnt * ZCOUNT_SCALE;
-
- printf("H\t%u\t%u\t%0.1f\t%u\t%u\t%u\n",
- msghdr->w1.msgtype,
- msghdr->w1.refstaid,
- zcount,
- msghdr->w2.sqnum,
- msghdr->w2.frmlen,
- msghdr->w2.stathlth);
- switch (msghdr->w1.msgtype) {
- case 1:
- case 9:
- {
- struct rtcm_msg1 *m = (struct rtcm_msg1 *) msghdr;
-
- while (len >= 0) {
- if (len >= 2)
- printf("S\t%u\t%u\t%u\t%0.1f\t%0.3f\t%0.3f\n",
- m->w3.satident1,
- m->w3.udre1,
- m->w4.issuedata1,
- zcount,
- m->w3.pc1 * (m->w3.scale1 ? PCLARGE : PCSMALL),
- m->w4.rangerate1 * (m->w3.scale1 ?
- RRLARGE : RRSMALL));
- if (len >= 4)
- printf("S\t%u\t%u\t%u\t%0.1f\t%0.3f\t%0.3f\n",
- m->w4.satident2,
- m->w4.udre2,
- m->w6.issuedata2,
- zcount,
- m->w5.pc2 * (m->w4.scale2 ? PCLARGE : PCSMALL),
- m->w5.rangerate2 * (m->w4.scale2 ?
- RRLARGE : RRSMALL));
-
- /*@ -shiftimplementation @*/
- if (len >= 5)
- printf("S\t%u\t%u\t%u\t%0.1f\t%0.3f\t%0.3f\n",
- m->w6.satident3,
- m->w6.udre3,
- m->w7.issuedata3,
- zcount,
- ((m->w6.pc3_h << 8) | (m->w7.pc3_l)) *
- (m->w6.scale3 ? PCLARGE : PCSMALL),
- m->w7.rangerate3 * (m->w6.scale3 ?
- RRLARGE : RRSMALL));
- /*@ +shiftimplementation @*/
- len -= 5;
- m = (struct rtcm_msg1 *) (((RTCMWORD *) m) + 5);
- }
- }
- break;
- default:
- break;
- }
-}
-
int main(int argc, char **argv)
{
int c;
struct rtcm_ctx ctxbuf, *ctx = &ctxbuf;
struct rtcm_msghdr *res;
+ char buf[BUFSIZ];
while ((c = getopt(argc, argv, "v:")) != EOF) {
switch (c) {
@@ -111,8 +51,10 @@ int main(int argc, char **argv)
while ((c = getchar()) != EOF) {
res = rtcm_decode(ctx, (unsigned int)c);
- if (res != RTCM_NO_SYNC && res != RTCM_SYNC)
- rtcm_print_msg(res);
+ if (res != RTCM_NO_SYNC && res != RTCM_SYNC) {
+ rtcm_dump(res, buf, sizeof(buf));
+ fputs(buf, stdout);
+ }
}
exit(0);
}