Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 1f08046

Browse files
author
Roman Gezikov
committed
Merge pull request #352 from dt-exafore/i241-iono-decoder-public
Add Iono decoder
2 parents f82b1f4 + 43f36bf commit 1f08046

File tree

9 files changed

+135
-12
lines changed

9 files changed

+135
-12
lines changed

include/libswiftnav/ephemeris.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 Swift Navigation Inc.
2+
* Copyright (C) 2010, 2016 Swift Navigation Inc.
33
* Contact: Henry Hallam <[email protected]>
44
* Fergus Noble <[email protected]>
55
*

include/libswiftnav/ionosphere.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015 Swift Navigation Inc.
2+
* Copyright (C) 2015, 2016 Swift Navigation Inc.
33
* Contact: Leith Bade <[email protected]>
44
*
55
* This source is subject to the license found in the file 'LICENSE' which must
@@ -27,4 +27,6 @@ double calc_ionosphere(const gps_time_t *t_gps,
2727
double a, double e,
2828
const ionosphere_t *i);
2929

30+
void decode_iono_parameters(const u32 *subframe4_words, ionosphere_t *iono);
31+
3032
#endif /* LIBSWIFTNAV_IONOSHPERE_H */

include/libswiftnav/nav_msg.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 Swift Navigation Inc.
2+
* Copyright (C) 2010, 2016 Swift Navigation Inc.
33
* Contact: Henry Hallam <[email protected]>
44
*
55
* This source is subject to the license found in the file 'LICENSE' which must
@@ -15,6 +15,7 @@
1515

1616
#include <libswiftnav/common.h>
1717
#include <libswiftnav/ephemeris.h>
18+
#include <libswiftnav/ionosphere.h>
1819

1920
#define NAV_MSG_SUBFRAME_BITS_LEN 14 /* Buffer 448 nav bits. */
2021

@@ -46,6 +47,9 @@ typedef struct {
4647
ephemeris_t ephemeris;
4748
bool ephemeris_upd_flag;
4849

50+
ionosphere_t iono;
51+
bool iono_corr_upd_flag;
52+
4953
u32 gps_l2c_sv_capability;
5054
bool gps_l2c_sv_capability_upd_flag;
5155
} gps_l1ca_decoded_data_t;

python/swiftnav/nav_msg.pxd

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2012 Swift Navigation Inc.
1+
# Copyright (C) 2012, 2016 Swift Navigation Inc.
22
#
33
# This source is subject to the license found in the file 'LICENSE' which must
44
# be be distributed together with this source. All other rights reserved.
@@ -30,9 +30,21 @@ cdef extern from "libswiftnav/nav_msg.h":
3030
u8 next_subframe_id
3131
s8 bit_polarity
3232

33+
ctypedef struct ionosphere_t:
34+
double a0
35+
double a1
36+
double a2
37+
double a3
38+
double b0
39+
double b1
40+
double b2
41+
double b3
42+
3343
ctypedef struct gps_l1ca_decoded_data_t:
3444
ephemeris_t ephemeris
3545
bool ephemeris_upd_flag
46+
ionosphere_t iono
47+
bool iono_corr_upd_flag
3648
u32 gps_l2c_sv_capability
3749
bool gps_l2c_sv_capability_upd_flag
3850

@@ -46,4 +58,4 @@ cdef class NavMsg:
4658
cdef nav_msg_t _thisptr
4759

4860
cdef class GpsL1CADecodedData:
49-
cdef gps_l1ca_decoded_data_t _thisptr
61+
cdef gps_l1ca_decoded_data_t _thisptr

python/swiftnav/nav_msg.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2012 Swift Navigation Inc.
1+
# Copyright (C) 2012, 2016 Swift Navigation Inc.
22
#
33
# This source is subject to the license found in the file 'LICENSE' which must
44
# be be distributed together with this source. All other rights reserved.

src/ephemeris.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 Swift Navigation Inc.
2+
* Copyright (C) 2010, 2016 Swift Navigation Inc.
33
* Contact: Henry Hallam <[email protected]>
44
* Fergus Noble <[email protected]>
55
*

src/ionosphere.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015 Swift Navigation Inc.
2+
* Copyright (C) 2015, 2016 Swift Navigation Inc.
33
* Contact: Leith Bade <[email protected]>
44
*
55
* This source is subject to the license found in the file 'LICENSE' which must
@@ -9,13 +9,14 @@
99
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
1010
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1111
*/
12-
1312
#include <float.h>
1413
#include <math.h>
1514
#include <stdio.h>
15+
#include <string.h>
1616

1717
#include <libswiftnav/constants.h>
1818
#include <libswiftnav/ionosphere.h>
19+
#include <libswiftnav/logging.h>
1920

2021
/** \defgroup ionosphere Ionospheric models
2122
* Implemenations of ionospheric delay correction models.
@@ -108,4 +109,35 @@ double calc_ionosphere(const gps_time_t *t_gps,
108109
return d_l1;
109110
}
110111

112+
/** The function decodes ionospheric parameters
113+
* \param subframe4_words pointer to received frame word,
114+
* Note: Ionospheric parmeters are passed in subframe 4,
115+
* pass function parameters accordingly.
116+
* \param iono pointer to ionosphere_t where decoded data should be stored
117+
*/
118+
void decode_iono_parameters(const u32 *subframe4_words, ionosphere_t *iono)
119+
{
120+
union {
121+
s8 s8;
122+
u8 u8;
123+
} onebyte;
124+
125+
onebyte.u8 = subframe4_words[3-3] >> (30-16) & 0xff; /* alfa 0 */
126+
iono->a0 = onebyte.s8 * pow(2, -30);
127+
onebyte.u8 = subframe4_words[3-3] >> (30-24) & 0xff; /* alfa 1 */
128+
iono->a1 = onebyte.s8 * pow(2, -27);
129+
onebyte.u8 = subframe4_words[4-3] >> (30-8) & 0xff; /* alfa 2 */
130+
iono->a2 = onebyte.s8 * pow(2, -24);
131+
onebyte.u8 = subframe4_words[4-3] >> (30-16) & 0xff; /* alfa 3 */
132+
iono->a3 = onebyte.s8 * pow(2, -24);
133+
onebyte.u8 = subframe4_words[4-3] >> (30-24) & 0xff; /* beta 0 */
134+
iono->b0 = onebyte.s8 * pow(2, 11);
135+
onebyte.u8 = subframe4_words[5-3] >> (30-8) & 0xff; /* beta 1 */
136+
iono->b1 = onebyte.s8 * pow(2, 14);
137+
onebyte.u8 = subframe4_words[5-3] >> (30-16) & 0xff; /* beta 2 */
138+
iono->b2 = onebyte.s8 * pow(2, 16);
139+
onebyte.u8 = subframe4_words[5-3] >> (30-24) & 0xff; /* beta 3 */
140+
iono->b3 = onebyte.s8 * pow(2, 16);
141+
}
142+
111143
/** \} */

src/nav_msg.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 Swift Navigation Inc.
2+
* Copyright (C) 2010, 2016 Swift Navigation Inc.
33
* Contact: Henry Hallam <[email protected]>
44
*
55
* This source is subject to the license found in the file 'LICENSE' which must
@@ -9,7 +9,6 @@
99
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
1010
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1111
*/
12-
1312
#include <stdio.h>
1413
#include <string.h>
1514
#include <stdlib.h>
@@ -20,6 +19,7 @@
2019
#include <libswiftnav/constants.h>
2120
#include <libswiftnav/bits.h>
2221
#include <libswiftnav/nav_msg.h>
22+
#include <libswiftnav/ionosphere.h>
2323
#include <libswiftnav/l2c_capability.h>
2424

2525
void nav_msg_init(nav_msg_t *n)
@@ -283,7 +283,6 @@ s8 process_subframe(nav_msg_t *n, gnss_signal_t sid,
283283
n->next_subframe_id++;
284284

285285
if (sf_id == 3) {
286-
287286
// Now let's actually decode the ephemeris...
288287
data->ephemeris.sid = sid;
289288
decode_ephemeris(n->frame_words, &data->ephemeris);
@@ -303,6 +302,15 @@ s8 process_subframe(nav_msg_t *n, gnss_signal_t sid,
303302
data->gps_l2c_sv_capability_upd_flag = true;
304303
}
305304

305+
/* check Word 3 bits 2..7 (63..69) for Page ID 18,
306+
* which contains iono data
307+
* Page 18 has ID 56, see IS-200H, pg. 109-110 */
308+
if ((n->frame_words[3][3-3] >> (30-8) & 0x3f) == 56) {
309+
/* decode ionospheric correction data */
310+
decode_iono_parameters(n->frame_words[3], &data->iono);
311+
data->iono_corr_upd_flag = true;
312+
}
313+
306314
/* Got all of subframes 1 to 4 */
307315
n->next_subframe_id = 1; /* Make sure we start again next time */
308316

tests/check_ionosphere.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
/*
2+
* Copyright (C) 2016 Swift Navigation Inc.
3+
* Contact: Dmitry Tatarinov <[email protected]>
4+
*
5+
* This source is subject to the license found in the file 'LICENSE' which must
6+
* be be distributed together with this source. All other rights reserved.
7+
*
8+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
9+
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
10+
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
112

213
#include <check.h>
14+
#include <stdio.h>
315

416
#include <libswiftnav/constants.h>
517
#include <libswiftnav/ionosphere.h>
@@ -49,12 +61,65 @@ START_TEST(test_calc_ionosphere)
4961
}
5062
END_TEST
5163

64+
START_TEST(test_decode_iono_parameters)
65+
{
66+
#define tol 1e-12
67+
struct {
68+
u32 frame_words[8];
69+
ionosphere_t result;
70+
} t_case = {
71+
.frame_words = {
72+
/* 4th SF real data at 11-May-2016 */
73+
0x1e0300c9,0x7fff8c24,0x23fbdc2,0,0,0,0,0
74+
},
75+
.result = { /* reference data provided by u-blox receiver */
76+
.a0 = 0.0000000111758,
77+
.a1 = 0.0000000223517,
78+
.a2 = -0.0000000596046,
79+
.a3 = -0.0000001192092,
80+
.b0 = 98304.0,
81+
.b1 = 131072.0,
82+
.b2 = -131072.0,
83+
.b3 = -589824.0,
84+
}
85+
};
86+
ionosphere_t i;
87+
decode_iono_parameters(t_case.frame_words, &i);
88+
fail_unless(fabs(i.a0 - t_case.result.a0) < tol,
89+
"alfa 0 == %30.20f, expected %30.20f, tolerance = %30.20f",
90+
i.a0, t_case.result.a0, tol);
91+
fail_unless(fabs(i.a1 - t_case.result.a1) < tol,
92+
"alfa 1 == %30.20f, expected %30.20f, tolerance = %30.20f",
93+
i.a1, t_case.result.a1, tol);
94+
fail_unless(fabs(i.a2 - t_case.result.a2) < tol,
95+
"alfa 2 == %30.20f, expected %30.20f, tolerance = %30.20f",
96+
i.a2, t_case.result.a2, tol);
97+
fail_unless(fabs(i.a3 - t_case.result.a3) < tol,
98+
"alfa 3 == %30.20f, expected %30.20f, tolerance = %30.20f",
99+
i.a3, t_case.result.a3, tol);
100+
fail_unless(fabs(i.b0 - t_case.result.b0) < tol,
101+
"beta 0 == %30.20f, expected %30.20f, tolerance = %30.20f",
102+
i.b0, t_case.result.b0, tol);
103+
fail_unless(fabs(i.b1 - t_case.result.b1) < tol,
104+
"beta 1 == %30.20f, expected %30.20f, tolerance = %30.20f",
105+
i.b1, t_case.result.b1, tol);
106+
fail_unless(fabs(i.b2 - t_case.result.b2) < tol,
107+
"beta 2 == %30.20f, expected %30.20f, tolerance = %30.20f",
108+
i.b2, t_case.result.b2, tol);
109+
fail_unless(fabs(i.b3 - t_case.result.b3) < tol,
110+
"beta 3 == %30.20f, expected %30.20f, tolerance = %30.20f",
111+
i.b3, t_case.result.b3, tol);
112+
113+
}
114+
END_TEST
115+
52116
Suite* ionosphere_suite(void)
53117
{
54118
Suite *s = suite_create("Ionosphere");
55119

56120
TCase *tc_core = tcase_create("Core");
57121
tcase_add_test(tc_core, test_calc_ionosphere);
122+
tcase_add_test(tc_core, test_decode_iono_parameters);
58123
suite_add_tcase(s, tc_core);
59124

60125
return s;

0 commit comments

Comments
 (0)