summaryrefslogtreecommitdiff
path: root/rtcm.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-07-22 21:56:36 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-07-22 21:56:36 +0000
commitf567b0cd7d21658203eec85b1df1649bc6a52102 (patch)
tree892502efc4bd7056b0d373ae3086a36a3ea57461 /rtcm.c
parent6f4ee6d917a368a44dc5f836be2fb218816eff0e (diff)
downloadgpsd-f567b0cd7d21658203eec85b1df1649bc6a52102.tar.gz
OK, substructures are all gathered. Now move to one big union.
Diffstat (limited to 'rtcm.c')
-rw-r--r--rtcm.c114
1 files changed, 48 insertions, 66 deletions
diff --git a/rtcm.c b/rtcm.c
index dd118020..70695721 100644
--- a/rtcm.c
+++ b/rtcm.c
@@ -253,72 +253,54 @@ struct rtcm_msghdr {
/* msg 1 - differential gps corrections */
-struct rtcm_msg1w3 { /* msg 1 word 3 */
- uint parity:6;
- int pc1:16;
- uint satident1:5; /* satellite ID */
- uint udre1:2;
- uint scale1:1;
- uint _pad:2;
-};
-
-struct rtcm_msg1w4 { /* msg 1 word 4 */
- uint parity:6;
- uint satident2:5; /* satellite ID */
- uint udre2:2;
- uint scale2:1;
- uint issuedata1:8;
- int rangerate1:8;
- uint _pad:2;
-};
-
-struct rtcm_msg1w5 { /* msg 1 word 5 */
- uint parity:6;
- int rangerate2:8;
- int pc2:16;
- uint _pad:2;
-};
-
-
-struct rtcm_msg1w6 { /* msg 1 word 6 */
- uint parity:6;
- int pc3_h:8;
- uint satident3:5; /* satellite ID */
- uint udre3:2;
- uint scale3:1;
- uint issuedata2:8;
- uint _pad:2;
-};
-
-struct rtcm_msg1w7 { /* msg 1 word 7 */
- uint parity:6;
- uint issuedata3:8;
- int rangerate3:8;
- uint pc3_l:8; /* NOTE: uint for low byte */
- uint _pad:2;
-};
-
struct rtcm_msg1 {
struct rtcm_msghw1 w1;
struct rtcm_msghw2 w2;
+ struct b_correction_t {
+ struct { /* msg 1 word 3 */
+ uint parity:6;
+ int pc1:16;
+ uint satident1:5; /* satellite ID */
+ uint udre1:2;
+ uint scale1:1;
+ uint _pad:2;
+ } w3;
+
+ struct { /* msg 1 word 4 */
+ uint parity:6;
+ uint satident2:5; /* satellite ID */
+ uint udre2:2;
+ uint scale2:1;
+ uint issuedata1:8;
+ int rangerate1:8;
+ uint _pad:2;
+ } w4;
- struct rtcm_msg1w3 w3; /* clump #1 of 5-corrections each */
- struct rtcm_msg1w4 w4;
- struct rtcm_msg1w5 w5;
- struct rtcm_msg1w6 w6;
- struct rtcm_msg1w7 w7;
-
- struct rtcm_msg1w3 w8; /* clump #2 of 5-corrections each */
- struct rtcm_msg1w4 w9;
- struct rtcm_msg1w5 w10;
- struct rtcm_msg1w6 w11;
- struct rtcm_msg1w7 w12;
-
- struct rtcm_msg1w3 w13; /* clump #3 of 5-corrections each */
- struct rtcm_msg1w4 w14;
- struct rtcm_msg1w5 w15;
- struct rtcm_msg1w6 w16;
- struct rtcm_msg1w7 w17;
+ struct { /* msg 1 word 5 */
+ uint parity:6;
+ int rangerate2:8;
+ int pc2:16;
+ uint _pad:2;
+ } w5;
+
+ struct { /* msg 1 word 6 */
+ uint parity:6;
+ int pc3_h:8;
+ uint satident3:5; /* satellite ID */
+ uint udre3:2;
+ uint scale3:1;
+ uint issuedata2:8;
+ uint _pad:2;
+ } w6;
+
+ struct { /* msg 1 word 7 */
+ uint parity:6;
+ uint issuedata3:8;
+ int rangerate3:8;
+ uint pc3_l:8; /* NOTE: uint for low byte */
+ uint _pad:2;
+ } w7;
+ } corrections[(RTCM_WORDS_MAX - 2) / 5];
};
/* msg 3 - reference station parameters */
@@ -536,7 +518,7 @@ static void unpack(struct gps_device_t *session)
case 1:
case 9:
{
- struct rtcm_msg1 *m = (struct rtcm_msg1 *) msghdr;
+ struct b_correction_t *m = &((struct rtcm_msg1 *) msghdr)->corrections[0];
while (len >= 0) {
if (len >= 2) {
@@ -572,7 +554,7 @@ static void unpack(struct gps_device_t *session)
n++;
}
len -= 5;
- m = (struct rtcm_msg1 *) (((rtcmword_t *) m) + 5);
+ m++;
}
tp->ranges.nentries = n;
}
@@ -711,7 +693,7 @@ static void repack(struct gps_device_t *session)
case 1:
case 9:
{
- struct rtcm_msg1 *m = (struct rtcm_msg1 *) msghdr;
+ struct b_correction_t *m = &((struct rtcm_msg1 *) msghdr)->corrections[0];
while (len >= 0) {
if (len >= 2) {
@@ -745,7 +727,7 @@ static void repack(struct gps_device_t *session)
n++;
}
len -= 5;
- m = (struct rtcm_msg1 *) (((rtcmword_t *) m) + 5);
+ m++;
}
tp->ranges.nentries = n;
}