source: ntrip/trunk/clock_and_orbit/clock_orbit_rtcm.c@ 1819

Last change on this file since 1819 was 1819, checked in by stoecker, 13 years ago

fixed warnings

  • Property svn:executable set to *
File size: 40.1 KB
Line 
1/* Programheader
2
3 Name: clock_orbit_rtcm.c
4 Project: RTCM3
5 Version: $Id: clock_orbit_rtcm.c,v 1.9 2009/04/24 09:17:24 weber Exp $
6 Authors: Dirk Stöcker
7 Description: state space approach for RTCM3
8*/
9
10#include <stdio.h>
11#include <string.h>
12#include <stdint.h>
13#include "clock_orbit_rtcm.h"
14
15static uint32_t CRC24(long size, const unsigned char *buf)
16{
17 uint32_t crc = 0;
18 int i;
19
20 while(size--)
21 {
22 crc ^= (*buf++) << (16);
23 for(i = 0; i < 8; i++)
24 {
25 crc <<= 1;
26 if(crc & 0x1000000)
27 crc ^= 0x01864cfb;
28 }
29 }
30 return crc;
31}
32
33/* NOTE: These defines are interlinked with below functions and directly modify
34the values. This may not be optimized in terms of final program code size but
35should be optimized in terms of speed.
36
37modified variables are:
38- everything defined in STARTDATA (only use ressize outside of the defines,
39 others are private)
40- buffer
41- size
42*/
43
44#ifndef NOENCODE
45#define STOREBITS \
46 while(numbits >= 8) \
47 { \
48 if(!size) return 0; \
49 *(buffer++) = bitbuffer>>(numbits-8); \
50 numbits -= 8; \
51 ++ressize; \
52 --size; \
53 }
54
55#define ADDBITS(a, b) \
56 { \
57 bitbuffer = (bitbuffer<<(a))|((b)&((1<<a)-1)); \
58 numbits += (a); \
59 STOREBITS \
60 }
61
62#define STARTDATA \
63 size_t ressize=0; \
64 char *blockstart; \
65 int numbits; \
66 uint64_t bitbuffer=0;
67
68#define INITBLOCK \
69 numbits = 0; \
70 blockstart = buffer; \
71 ADDBITS(8, 0xD3) \
72 ADDBITS(6, 0) \
73 ADDBITS(10, 0)
74
75#define ENDBLOCK \
76 if(numbits) { ADDBITS((8-numbits), 0) } \
77 { \
78 int len = buffer-blockstart-3; \
79 blockstart[1] |= len>>8; \
80 blockstart[2] = len; \
81 len = CRC24(len+3, (const unsigned char *) blockstart); \
82 ADDBITS(24, len) \
83 }
84
85#define SCALEADDBITS(a, b, c) ADDBITS(a, (int64_t)(b*c))
86
87/* standard values */
88#define T_MESSAGE_NUMBER(a) ADDBITS(12, a) /* DF002 */
89#define T_RESERVED5 ADDBITS(5, 0) /* DF001 */
90#define T_GPS_SATELLITE_ID(a) ADDBITS(6, a) /* DF068 */
91#define T_GPS_IODE(a) ADDBITS(8, a) /* DF071 */
92#define T_GLONASS_IOD(a) ADDBITS(8, a) /* DF237 */
93
94/* defined values */
95#define T_DELTA_RADIAL(a) SCALEADDBITS(22, 10000.0, a)
96#define T_DELTA_ALONG_TRACK(a) SCALEADDBITS(20, 2500.0, a)
97#define T_DELTA_CROSS_TRACK(a) SCALEADDBITS(20, 2500.0, a)
98#define T_DELTA_DOT_RADIAL(a) SCALEADDBITS(21, 1000000.0, a)
99#define T_DELTA_DOT_ALONG_TRACK(a) SCALEADDBITS(19, 250000.0, a)
100#define T_DELTA_DOT_CROSS_TRACK(a) SCALEADDBITS(19, 250000.0, a)
101#define T_DELTA_DOT_DOT_RADIAL(a) SCALEADDBITS(27, 50000000.0, a)
102#define T_DELTA_DOT_DOT_ALONG_TRACK(a) SCALEADDBITS(25, 12500000.0, a)
103#define T_DELTA_DOT_DOT_CROSS_TRACK(a) SCALEADDBITS(25, 12500000.0, a)
104#define T_SATELLITE_REFERENCE_POINT(a) ADDBITS(1, a)
105
106#define T_SATELLITE_REFERENCE_DATUM(a) ADDBITS(1, a)
107#define T_DELTA_CLOCK_C0(a) SCALEADDBITS(22, 10000.0, a)
108#define T_DELTA_CLOCK_C1(a) SCALEADDBITS(21, 1000000.0, a)
109#define T_DELTA_CLOCK_C2(a) SCALEADDBITS(27, 50000000.0, a)
110#define T_NO_OF_CODE_BIASES(a) ADDBITS(5, a)
111#define T_GPS_SIGNAL_IDENTIFIER(a) ADDBITS(5, a)
112#define T_GLONASS_SIGNAL_IDENTIFIER(a) ADDBITS(5, a)
113#define T_GALILEO_SIGNAL_IDENTIFIER(a) ADDBITS(5, a)
114#define T_CODE_BIAS(a) SCALEADDBITS(14, 100.0, a)
115#define T_GLONASS_SATELLITE_ID(a) ADDBITS(5, a)
116
117#define T_GPS_EPOCH_TIME(a) ADDBITS(20, a)
118#define T_GLONASS_EPOCH_TIME(a) ADDBITS(17, a)
119#define T_NO_OF_SATELLITES(a) ADDBITS(6, a)
120#define T_MULTIPLE_MESSAGE_INDICATOR(a) ADDBITS(1, a)
121#define T_SSR_URA(a) ADDBITS(4, a)
122#define T_HR_CLOCK_CORRECTION(a) SCALEADDBITS(22, 10000.0, a)
123#define T_SSR_UPDATE_INTERVAL(a) ADDBITS(4, a)
124
125size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type,
126int moremessagesfollow, char *buffer, size_t size)
127{
128 int gpshr=0, gpsur=0, gpsor=0, gpscl=0, gpsco=0, glohr=0, glour=0, gloor=0,
129 glocl=0, gloco=0, mmi, i;
130
131 STARTDATA
132
133 if(co->NumberOfGPSSat && co->HRDataSupplied
134 && (type == COTYPE_AUTO || type == COTYPE_GPSHR))
135 gpshr = 1;
136 if(co->NumberOfGPSSat && co->URADataSupplied
137 && (type == COTYPE_AUTO || type == COTYPE_GPSURA))
138 gpsur = 1;
139 if(co->NumberOfGPSSat && co->OrbitDataSupplied
140 && (type == COTYPE_AUTO || type == COTYPE_GPSORBIT))
141 gpsor = 1;
142 if(co->NumberOfGPSSat && co->ClockDataSupplied
143 && (type == COTYPE_AUTO || type == COTYPE_GPSCLOCK))
144 gpscl = 1;
145 if(co->NumberOfGPSSat && co->ClockDataSupplied && co->OrbitDataSupplied
146 && (type == COTYPE_AUTO || type == COTYPE_GPSCOMBINED))
147 {
148 gpsco = 1; gpsor = 0; gpscl = 0;
149 }
150 if(co->NumberOfGLONASSSat && co->HRDataSupplied
151 && (type == COTYPE_AUTO || type == COTYPE_GLONASSHR))
152 glohr = 1;
153 if(co->NumberOfGLONASSSat && co->URADataSupplied
154 && (type == COTYPE_AUTO || type == COTYPE_GLONASSURA))
155 glour = 1;
156 if(co->NumberOfGLONASSSat && co->OrbitDataSupplied
157 && (type == COTYPE_AUTO || type == COTYPE_GLONASSORBIT))
158 gloor = 1;
159 if(co->NumberOfGLONASSSat && co->ClockDataSupplied
160 && (type == COTYPE_AUTO || type == COTYPE_GLONASSCLOCK))
161 glocl = 1;
162 if(co->NumberOfGLONASSSat && co->ClockDataSupplied && co->OrbitDataSupplied
163 && (type == COTYPE_AUTO || type == COTYPE_GLONASSCOMBINED))
164 {
165 gloco = 1; gloor = 0; glocl = 0;
166 }
167
168 mmi = gpshr+gpsur+gpsor+gpscl+gpsco+glohr+glour+gloor+glocl+gloco; /* required for multimessage */
169 if(!moremessagesfollow) --mmi;
170
171 if(gpsor)
172 {
173 INITBLOCK
174 T_MESSAGE_NUMBER(COTYPE_GPSORBIT)
175 T_GPS_EPOCH_TIME(co->GPSEpochTime)
176 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
177 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
178 --mmi;
179 T_RESERVED5
180 T_NO_OF_SATELLITES(co->NumberOfGPSSat)
181 for(i = 0; i < co->NumberOfGPSSat; ++i)
182 {
183 T_GPS_SATELLITE_ID(co->Sat[i].ID)
184 T_GPS_IODE(co->Sat[i].IOD)
185 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
186 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
187 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
188 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
189 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
190 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
191 T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
192 T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
193 T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
194 T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
195 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
196 }
197 ENDBLOCK
198 }
199 if(gpscl)
200 {
201 INITBLOCK
202 T_MESSAGE_NUMBER(COTYPE_GPSCLOCK)
203 T_GPS_EPOCH_TIME(co->GPSEpochTime)
204 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
205 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
206 --mmi;
207 T_RESERVED5
208 T_NO_OF_SATELLITES(co->NumberOfGPSSat)
209 for(i = 0; i < co->NumberOfGPSSat; ++i)
210 {
211 T_GPS_SATELLITE_ID(co->Sat[i].ID)
212 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
213 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
214 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
215 }
216 ENDBLOCK
217 }
218 if(gpsco)
219 {
220 INITBLOCK
221 T_MESSAGE_NUMBER(COTYPE_GPSCOMBINED)
222 T_GPS_EPOCH_TIME(co->GPSEpochTime)
223 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
224 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
225 --mmi;
226 T_RESERVED5
227 T_NO_OF_SATELLITES(co->NumberOfGPSSat)
228 for(i = 0; i < co->NumberOfGPSSat; ++i)
229 {
230 T_GPS_SATELLITE_ID(co->Sat[i].ID)
231 T_GPS_IODE(co->Sat[i].IOD)
232 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
233 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
234 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
235 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
236 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
237 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
238 T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
239 T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
240 T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
241 T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
242 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
243 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
244 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
245 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
246 }
247 ENDBLOCK
248 }
249 if(gpshr)
250 {
251 INITBLOCK
252 T_MESSAGE_NUMBER(COTYPE_GPSHR)
253 T_GPS_EPOCH_TIME(co->GPSEpochTime)
254 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
255 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
256 --mmi;
257 T_RESERVED5
258 T_NO_OF_SATELLITES(co->NumberOfGPSSat)
259 for(i = 0; i < co->NumberOfGPSSat; ++i)
260 {
261 T_GPS_SATELLITE_ID(co->Sat[i].ID)
262 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)
263 }
264 ENDBLOCK
265 }
266 if(gpsur)
267 {
268 INITBLOCK
269 T_MESSAGE_NUMBER(COTYPE_GPSURA)
270 T_GPS_EPOCH_TIME(co->GPSEpochTime)
271 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
272 --mmi;
273 T_RESERVED5
274 T_NO_OF_SATELLITES(co->NumberOfGPSSat)
275 for(i = 0; i < co->NumberOfGPSSat; ++i)
276 {
277 T_GPS_SATELLITE_ID(co->Sat[i].ID)
278 T_SSR_URA(co->Sat[i].URA)
279 }
280 ENDBLOCK
281 }
282 if(gloor)
283 {
284 INITBLOCK
285 T_MESSAGE_NUMBER(COTYPE_GLONASSORBIT)
286 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)
287 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
288 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
289 --mmi;
290 T_RESERVED5
291 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
292 for(i = CLOCKORBIT_NUMGPS;
293 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
294 {
295 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
296 T_GLONASS_IOD(co->Sat[i].IOD)
297 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
298 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
299 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
300 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
301 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
302 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
303 T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
304 T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
305 T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
306 T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
307 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
308 }
309 ENDBLOCK
310 }
311 if(glocl)
312 {
313 INITBLOCK
314 T_MESSAGE_NUMBER(COTYPE_GLONASSCLOCK)
315 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)
316 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
317 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
318 --mmi;
319 T_RESERVED5
320 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
321 for(i = CLOCKORBIT_NUMGPS;
322 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
323 {
324 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
325 T_GLONASS_IOD(co->Sat[i].IOD)
326 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
327 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
328 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
329 }
330 ENDBLOCK
331 }
332 if(gloco)
333 {
334 INITBLOCK
335 T_MESSAGE_NUMBER(COTYPE_GLONASSCOMBINED)
336 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)
337 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
338 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
339 --mmi;
340 T_RESERVED5
341 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
342 for(i = CLOCKORBIT_NUMGPS;
343 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
344 {
345 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
346 T_GLONASS_IOD(co->Sat[i].IOD)
347 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
348 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
349 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
350 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
351 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
352 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
353 T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
354 T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
355 T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
356 T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
357 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
358 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
359 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
360 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
361 }
362 ENDBLOCK
363 }
364 if(glohr)
365 {
366 INITBLOCK
367 T_MESSAGE_NUMBER(COTYPE_GLONASSHR)
368 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)
369 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
370 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
371 --mmi;
372 T_RESERVED5
373 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
374 for(i = CLOCKORBIT_NUMGPS;
375 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
376 {
377 T_GPS_SATELLITE_ID(co->Sat[i].ID)
378 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)
379 }
380 ENDBLOCK
381 }
382 if(glour)
383 {
384 INITBLOCK
385 T_MESSAGE_NUMBER(COTYPE_GLONASSURA)
386 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)
387 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
388 --mmi;
389 T_RESERVED5
390 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
391 for(i = CLOCKORBIT_NUMGPS;
392 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
393 {
394 T_GPS_SATELLITE_ID(co->Sat[i].ID)
395 T_SSR_URA(co->Sat[i].URA)
396 }
397 ENDBLOCK
398 }
399
400
401 return ressize;
402}
403
404size_t MakeBias(const struct Bias *b, enum BiasType type,
405int moremessagesfollow, char *buffer, size_t size)
406{
407 int gps, glo, mmi, i, j;
408
409 STARTDATA
410
411 if(b->NumberOfGPSSat && (type == BTYPE_AUTO || type == BTYPE_GPS))
412 gps = 1;
413 if(b->NumberOfGLONASSSat && (type == BTYPE_AUTO || type == BTYPE_GLONASS))
414 glo = 1;
415
416 mmi = gps+glo; /* required for multimessage */
417 if(!moremessagesfollow) --mmi;
418
419 if(gps)
420 {
421 INITBLOCK
422 T_MESSAGE_NUMBER(BTYPE_GPS)
423 T_GPS_EPOCH_TIME(b->GPSEpochTime)
424 T_SSR_UPDATE_INTERVAL(b->UpdateInterval)
425 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
426 --mmi;
427 T_RESERVED5
428 T_NO_OF_SATELLITES(b->NumberOfGPSSat)
429 for(i = 0; i < b->NumberOfGPSSat; ++i)
430 {
431 T_GPS_SATELLITE_ID(b->Sat[i].ID)
432 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
433 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
434 {
435 T_GPS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
436 T_CODE_BIAS(b->Sat[i].Biases[j].Bias)
437 }
438 }
439 ENDBLOCK
440 }
441 if(glo)
442 {
443 INITBLOCK
444 T_MESSAGE_NUMBER(BTYPE_GLONASS)
445 T_GPS_EPOCH_TIME(b->GLONASSEpochTime)
446 T_SSR_UPDATE_INTERVAL(b->UpdateInterval)
447 T_MULTIPLE_MESSAGE_INDICATOR(mmi ? 1 :0)
448 --mmi;
449 T_RESERVED5
450 T_NO_OF_SATELLITES(b->NumberOfGLONASSSat)
451 for(i = CLOCKORBIT_NUMGPS;
452 i < CLOCKORBIT_NUMGPS+b->NumberOfGLONASSSat; ++i)
453 {
454 T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
455 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
456 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
457 {
458 T_GLONASS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
459 T_CODE_BIAS(b->Sat[i].Biases[j].Bias)
460 }
461 }
462 ENDBLOCK
463 }
464
465 return ressize;
466}
467
468#endif /* NOENCODE */
469
470#ifndef NODECODE
471
472#define DECODESTART \
473 int numbits=0; \
474 uint64_t bitbuffer=0;
475
476#define LOADBITS(a) \
477{ \
478 while((a) > numbits) \
479 { \
480 if(!size--) return GCOBR_SHORTMESSAGE; \
481 bitbuffer = (bitbuffer<<8)|((unsigned char)*(buffer++)); \
482 numbits += 8; \
483 } \
484}
485
486/* extract bits from data stream
487 b = variable to store result, a = number of bits */
488#define GETBITS(b, a) \
489{ \
490 LOADBITS(a) \
491 b = (bitbuffer<<(64-numbits))>>(64-(a)); \
492 numbits -= (a); \
493}
494
495/* extract signed floating value from data stream
496 b = variable to store result, a = number of bits */
497#define GETFLOATSIGN(b, a, c) \
498{ \
499 LOADBITS(a) \
500 b = ((double)(((int64_t)(bitbuffer<<(64-numbits)))>>(64-(a))))*(c); \
501 numbits -= (a); \
502}
503
504#define SKIPBITS(b) { LOADBITS(b) numbits -= (b); }
505
506/* standard values */
507#define G_HEADER(a) GETBITS(a,8)
508#define G_RESERVEDH(a) GETBITS(a,6)
509#define G_SIZE(a) GETBITS(a, 10)
510#define G_MESSAGE_NUMBER(a) GETBITS(a, 12) /* DF002 */
511#define G_RESERVED5 SKIPBITS(5) /* DF001 */
512#define G_GPS_SATELLITE_ID(a) {int temp; GETBITS(temp, 6) \
513 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;} /* DF068 */
514#define G_GPS_IODE(a) GETBITS(a, 8) /* DF071 */
515#define G_GLONASS_IOD(a) GETBITS(a, 8) /* DF237 */
516
517/* defined values */
518#define G_DELTA_RADIAL(a) GETFLOATSIGN(a, 22, 1/10000.0)
519#define G_DELTA_ALONG_TRACK(a) GETFLOATSIGN(a, 20, 1/2500.0)
520#define G_DELTA_CROSS_TRACK(a) GETFLOATSIGN(a, 20, 1/2500.0)
521#define G_DELTA_DOT_RADIAL(a) GETFLOATSIGN(a, 21, 1/1000000.0)
522#define G_DELTA_DOT_ALONG_TRACK(a) GETFLOATSIGN(a, 19, 1/250000.0)
523#define G_DELTA_DOT_CROSS_TRACK(a) GETFLOATSIGN(a, 19, 1/250000.0)
524#define G_DELTA_DOT_DOT_RADIAL(a) GETFLOATSIGN(a, 27, 1/50000000.0)
525#define G_DELTA_DOT_DOT_ALONG_TRACK(a) GETFLOATSIGN(a, 25, 1/12500000.0)
526#define G_DELTA_DOT_DOT_CROSS_TRACK(a) GETFLOATSIGN(a, 25, 1/12500000.0)
527#define G_SATELLITE_REFERENCE_POINT(a) GETBITS(a, 1)
528
529#define G_SATELLITE_REFERENCE_DATUM(a) GETBITS(a, 1)
530#define G_DELTA_CLOCK_C0(a) GETFLOATSIGN(a, 22, 1/10000.0)
531#define G_DELTA_CLOCK_C1(a) GETFLOATSIGN(a, 21, 1/1000000.0)
532#define G_DELTA_CLOCK_C2(a) GETFLOATSIGN(a, 27, 1/50000000.0)
533#define G_NO_OF_CODE_BIASES(a) GETBITS(a, 5)
534#define G_GPS_SIGNAL_IDENTIFIER(a) GETBITS(a, 5)
535#define G_GLONASS_SIGNAL_IDENTIFIER(a) GETBITS(a, 5)
536#define G_GALILEO_SIGNAL_IDENTIFIER(a) GETBITS(a, 5)
537#define G_CODE_BIAS(a) GETFLOATSIGN(a, 14, 1/100.0)
538#define G_GLONASS_SATELLITE_ID(a) {int temp; GETBITS(temp, 5) \
539 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;}
540
541#define G_GPS_EPOCH_TIME(a, b) {int temp; GETBITS(temp, 20) \
542 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;}
543#define G_GLONASS_EPOCH_TIME(a, b) {int temp; GETBITS(temp, 17) \
544 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;}
545#define G_NO_OF_SATELLITES(a) {int temp; GETBITS(temp, 6) \
546 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;}
547#define G_MULTIPLE_MESSAGE_INDICATOR(a) GETBITS(a, 1)
548#define G_SSR_URA(a) GETBITS(a, 4)
549#define G_HR_CLOCK_CORRECTION(a) GETFLOATSIGN(a, 22, 1/10000.0)
550#define G_SSR_UPDATE_INTERVAL(a) GETBITS(a, 4)
551
552#ifdef OLD
553enum OldClockOrbitType { OLDCOTYPE_GPSORBIT=4050, OLDCOTYPE_GPSCLOCK=4051,
554 OLDCOTYPE_GLONASSORBIT=4053, OLDCOTYPE_GLONASSCLOCK=4054,
555 OLDCOTYPE_GPSCOMBINED=4056, OLDCOTYPE_GLONASSCOMBINED=4057};
556enum OldBiasType { OLDBTYPE_GPS=4052, OLDBTYPE_GLONASS=4055};
557#define OLD_G_RESERVED6 SKIPBITS(6) /* DF001 */
558#define OLD_G_GLONASS_SATELLITE_ID(a) {int temp; GETBITS(temp, 6) \
559 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;}
560#define OLD_G_NO_OF_SATELLITES(a) {int temp; GETBITS(temp, 5) \
561 if(a && a != temp) return GCOBR_DATAMISMATCH; a = temp;}
562#define OLD_G_DELTA_RADIAL(a) GETFLOATSIGN(a, 20, 1/1000.0)
563#define OLD_G_DELTA_ALONG_TRACK(a) GETFLOATSIGN(a, 20, 1/1000.0)
564#define OLD_G_DELTA_CROSS_TRACK(a) GETFLOATSIGN(a, 20, 1/1000.0)
565#define OLD_G_DELTA_DOT_RADIAL(a) GETFLOATSIGN(a, 20, 1/100000.0)
566#define OLD_G_DELTA_DOT_ALONG_TRACK(a) GETFLOATSIGN(a, 20, 1/100000.0)
567#define OLD_G_DELTA_DOT_CROSS_TRACK(a) GETFLOATSIGN(a, 20, 1/100000.0)
568#define OLD_G_DELTA_DOT_DOT_RADIAL(a) GETFLOATSIGN(a, 20, 1/5000000.0)
569#define OLD_G_DELTA_DOT_DOT_ALONG_TRACK(a) GETFLOATSIGN(a, 20, 1/5000000.0)
570#define OLD_G_DELTA_DOT_DOT_CROSS_TRACK(a) GETFLOATSIGN(a, 20, 1/5000000.0)
571#define OLD_G_DELTA_A0(a) GETFLOATSIGN(a, 20, 1/1000.0)
572#define OLD_G_DELTA_A1(a) GETFLOATSIGN(a, 20, 1/100000.0)
573#define OLD_G_DELTA_A2(a) GETFLOATSIGN(a, 20, 1/5000000.0)
574#define OLD_G_CODE_BIAS(a) GETFLOATSIGN(a, 20, 1/100.0)
575#endif
576
577enum GCOB_RETURN GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b,
578const char *buffer, size_t size, int *bytesused)
579{
580 int type, mmi=0, i, j, h, rs;
581 size_t sizeofrtcmblock;
582 const char *blockstart = buffer;
583 DECODESTART
584
585 if(size < 7)
586 return GCOBR_SHORTBUFFER;
587
588 G_HEADER(h)
589 G_RESERVEDH(rs)
590 G_SIZE(sizeofrtcmblock);
591
592 if((unsigned char)h != 0xD3 || rs)
593 return GCOBR_UNKNOWNDATA;
594 if(size < sizeofrtcmblock + 3) /* 3 header bytes already removed */
595 return GCOBR_MESSAGEEXCEEDSBUFFER;
596 if(CRC24(sizeofrtcmblock+3, (const unsigned char *) blockstart) !=
597 (uint32_t)((((unsigned char)buffer[sizeofrtcmblock])<<16)|
598 (((unsigned char)buffer[sizeofrtcmblock+1])<<8)|
599 (((unsigned char)buffer[sizeofrtcmblock+2]))))
600 return GCOBR_CRCMISMATCH;
601 size = sizeofrtcmblock; /* reduce size, so overflows are detected */
602
603 G_MESSAGE_NUMBER(type)
604#ifdef DEBUG
605fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock);
606#endif
607 switch(type)
608 {
609 case COTYPE_GPSORBIT:
610 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
611 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
612 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
613 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
614 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
615 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
616 G_RESERVED5
617 G_NO_OF_SATELLITES(co->NumberOfGPSSat)
618 if(co->OrbitDataSupplied)
619 return GCOBR_DATAMISMATCH;
620 co->OrbitDataSupplied = 1;
621#ifdef DEBUG
622fprintf(stderr, "epochtime %d ui %d mmi %d sats %d\n",co->GPSEpochTime,co->UpdateInterval,mmi,co->NumberOfGPSSat);
623#endif
624 for(i = 0; i < co->NumberOfGPSSat; ++i)
625 {
626 G_GPS_SATELLITE_ID(co->Sat[i].ID)
627 G_GPS_IODE(co->Sat[i].IOD)
628 G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
629 G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
630 G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
631 G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
632 G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
633 G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
634 G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
635 G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
636 G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
637 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
638 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
639#ifdef DEBUG
640fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f rp %d rd %d\n",
641co->Sat[i].ID,co->Sat[i].IOD,co->Sat[i].Orbit.DeltaRadial,
642co->Sat[i].Orbit.DeltaAlongTrack,co->Sat[i].Orbit.DeltaCrossTrack,
643co->Sat[i].Orbit.DotDeltaRadial,
644co->Sat[i].Orbit.DotDeltaAlongTrack,
645co->Sat[i].Orbit.DotDeltaCrossTrack,
646co->Sat[i].Orbit.DotDotDeltaRadial,
647co->Sat[i].Orbit.DotDotDeltaAlongTrack,
648co->Sat[i].Orbit.DotDotDeltaCrossTrack,
649co->SatRefPoint,
650co->SatRefDatum);
651#endif
652 }
653 break;
654 case COTYPE_GPSCLOCK:
655 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
656 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
657 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
658 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
659 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
660 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
661 G_RESERVED5
662 G_NO_OF_SATELLITES(co->NumberOfGPSSat)
663 if(co->ClockDataSupplied)
664 return GCOBR_DATAMISMATCH;
665 co->ClockDataSupplied = 1;
666 for(i = 0; i < co->NumberOfGPSSat; ++i)
667 {
668 G_GPS_SATELLITE_ID(co->Sat[i].ID)
669 G_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
670 G_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
671 G_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
672 }
673 break;
674 case COTYPE_GPSCOMBINED:
675 if(!co) return -5;
676 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
677 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
678 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
679 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
680 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
681 G_RESERVED5
682 G_NO_OF_SATELLITES(co->NumberOfGPSSat)
683 if(co->ClockDataSupplied || co->OrbitDataSupplied)
684 return GCOBR_DATAMISMATCH;
685 co->OrbitDataSupplied = 1;
686 co->ClockDataSupplied = 1;
687 for(i = 0; i < co->NumberOfGPSSat; ++i)
688 {
689 G_GPS_SATELLITE_ID(co->Sat[i].ID)
690 G_GPS_IODE(co->Sat[i].IOD)
691 G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
692 G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
693 G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
694 G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
695 G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
696 G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
697 G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
698 G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
699 G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
700 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
701 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
702 G_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
703 G_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
704 G_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
705 }
706 break;
707 case COTYPE_GPSURA:
708 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
709 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
710 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
711 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
712 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
713 G_RESERVED5
714 G_NO_OF_SATELLITES(co->NumberOfGPSSat)
715 if(co->URADataSupplied)
716 return GCOBR_DATAMISMATCH;
717 co->URADataSupplied = 1;
718 for(i = 0; i < co->NumberOfGPSSat; ++i)
719 {
720 G_GPS_SATELLITE_ID(co->Sat[i].ID)
721 G_SSR_URA(co->Sat[i].URA)
722 }
723 break;
724 case COTYPE_GPSHR:
725 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
726 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
727 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
728 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
729 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
730 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
731 G_RESERVED5
732 G_NO_OF_SATELLITES(co->NumberOfGPSSat)
733 if(co->HRDataSupplied)
734 return GCOBR_DATAMISMATCH;
735 co->HRDataSupplied = 1;
736 for(i = 0; i < co->NumberOfGPSSat; ++i)
737 {
738 G_GPS_SATELLITE_ID(co->Sat[i].ID)
739 G_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)
740 }
741 break;
742 case COTYPE_GLONASSORBIT:
743 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
744 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
745 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
746 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
747 G_RESERVED5
748 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
749 if(co->OrbitDataSupplied)
750 return GCOBR_DATAMISMATCH;
751 co->OrbitDataSupplied = 1;
752 for(i = CLOCKORBIT_NUMGPS;
753 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
754 {
755 G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
756 G_GLONASS_IOD(co->Sat[i].IOD)
757 G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
758 G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
759 G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
760 G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
761 G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
762 G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
763 G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
764 G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
765 G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
766 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
767 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
768 }
769 break;
770 case COTYPE_GLONASSCLOCK:
771 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
772 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
773 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
774 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
775 G_RESERVED5
776 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
777 if(co->ClockDataSupplied)
778 return GCOBR_DATAMISMATCH;
779 co->ClockDataSupplied = 1;
780 for(i = CLOCKORBIT_NUMGPS;
781 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
782 {
783 G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
784 G_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
785 G_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
786 G_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
787 }
788 break;
789 case COTYPE_GLONASSCOMBINED:
790 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
791 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
792 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
793 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
794 G_RESERVED5
795 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
796 if(co->ClockDataSupplied || co->OrbitDataSupplied)
797 return GCOBR_DATAMISMATCH;
798 co->OrbitDataSupplied = 1;
799 co->ClockDataSupplied = 1;
800 for(i = CLOCKORBIT_NUMGPS;
801 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
802 {
803 G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
804 G_GLONASS_IOD(co->Sat[i].IOD)
805 G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
806 G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
807 G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
808 G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
809 G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
810 G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
811 G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
812 G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
813 G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
814 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
815 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
816 G_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
817 G_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
818 G_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
819 }
820 break;
821 case COTYPE_GLONASSURA:
822 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
823 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
824 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
825 G_RESERVED5
826 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
827 if(co->URADataSupplied)
828 return GCOBR_DATAMISMATCH;
829 co->URADataSupplied = 1;
830 for(i = CLOCKORBIT_NUMGPS;
831 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
832 {
833 G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
834 G_SSR_URA(co->Sat[i].URA)
835 }
836 break;
837 case COTYPE_GLONASSHR:
838 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
839 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
840 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
841 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
842 G_RESERVED5
843 G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
844 if(co->HRDataSupplied)
845 return GCOBR_DATAMISMATCH;
846 co->HRDataSupplied = 1;
847 for(i = CLOCKORBIT_NUMGPS;
848 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
849 {
850 G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
851 G_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)
852 }
853 break;
854 case BTYPE_GPS:
855 if(!b) return GCOBR_NOBIASPARAMETER;
856 G_GPS_EPOCH_TIME(b->GPSEpochTime, co->NumberOfGPSSat)
857 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
858 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
859 G_RESERVED5
860 G_NO_OF_SATELLITES(b->NumberOfGPSSat)
861 for(i = 0; i < b->NumberOfGPSSat; ++i)
862 {
863 G_GPS_SATELLITE_ID(b->Sat[i].ID)
864 G_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
865 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
866 {
867 G_GPS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
868 G_CODE_BIAS(b->Sat[i].Biases[j].Bias)
869 }
870 }
871 break;
872 case BTYPE_GLONASS:
873 if(!b) return GCOBR_NOBIASPARAMETER;
874 G_GPS_EPOCH_TIME(b->GLONASSEpochTime, co->NumberOfGLONASSSat)
875 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
876 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
877 G_RESERVED5
878 G_NO_OF_SATELLITES(b->NumberOfGLONASSSat)
879 for(i = CLOCKORBIT_NUMGPS;
880 i < CLOCKORBIT_NUMGPS+b->NumberOfGLONASSSat; ++i)
881 {
882 G_GLONASS_SATELLITE_ID(b->Sat[i].ID)
883 G_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
884 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
885 {
886 G_GLONASS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
887 G_CODE_BIAS(b->Sat[i].Biases[j].Bias)
888 }
889 }
890 break;
891#ifdef OLD
892 case OLDCOTYPE_GPSORBIT:
893 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
894 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
895 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
896 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
897 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
898 OLD_G_RESERVED6
899 OLD_G_NO_OF_SATELLITES(co->NumberOfGPSSat)
900 if(co->OrbitDataSupplied)
901 return GCOBR_DATAMISMATCH;
902 co->OrbitDataSupplied = 1;
903 for(i = 0; i < co->NumberOfGPSSat; ++i)
904 {
905 G_GPS_SATELLITE_ID(co->Sat[i].ID)
906 G_GPS_IODE(co->Sat[i].IOD)
907 OLD_G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
908 OLD_G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
909 OLD_G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
910 OLD_G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
911 OLD_G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
912 OLD_G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
913 OLD_G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
914 OLD_G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
915 OLD_G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
916 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
917 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
918 }
919 break;
920 case OLDCOTYPE_GPSCLOCK:
921 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
922 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
923 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
924 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
925 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
926 OLD_G_RESERVED6
927 OLD_G_NO_OF_SATELLITES(co->NumberOfGPSSat)
928 if(co->ClockDataSupplied)
929 return GCOBR_DATAMISMATCH;
930 co->ClockDataSupplied = 1;
931 for(i = 0; i < co->NumberOfGPSSat; ++i)
932 {
933 G_GPS_SATELLITE_ID(co->Sat[i].ID)
934 G_GPS_IODE(co->Sat[i].IOD)
935 OLD_G_DELTA_A0(co->Sat[i].Clock.DeltaA0)
936 OLD_G_DELTA_A1(co->Sat[i].Clock.DeltaA1)
937 OLD_G_DELTA_A2(co->Sat[i].Clock.DeltaA2)
938 }
939 break;
940 case OLDCOTYPE_GPSCOMBINED:
941 if(!co) return -5;
942 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)
943 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */
944 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */
945 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
946 OLD_G_RESERVED6
947 OLD_G_NO_OF_SATELLITES(co->NumberOfGPSSat)
948 if(co->ClockDataSupplied || co->OrbitDataSupplied)
949 return GCOBR_DATAMISMATCH;
950 co->OrbitDataSupplied = 1;
951 co->ClockDataSupplied = 1;
952 for(i = 0; i < co->NumberOfGPSSat; ++i)
953 {
954 G_GPS_SATELLITE_ID(co->Sat[i].ID)
955 G_GPS_IODE(co->Sat[i].IOD)
956 OLD_G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
957 OLD_G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
958 OLD_G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
959 OLD_G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
960 OLD_G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
961 OLD_G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
962 OLD_G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
963 OLD_G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
964 OLD_G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
965 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
966 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
967 OLD_G_DELTA_A0(co->Sat[i].Clock.DeltaA0)
968 OLD_G_DELTA_A1(co->Sat[i].Clock.DeltaA1)
969 OLD_G_DELTA_A2(co->Sat[i].Clock.DeltaA2)
970 }
971 break;
972 case OLDCOTYPE_GLONASSORBIT:
973 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
974 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
975 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
976 OLD_G_RESERVED6
977 OLD_G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
978 if(co->OrbitDataSupplied)
979 return GCOBR_DATAMISMATCH;
980 co->OrbitDataSupplied = 1;
981 for(i = CLOCKORBIT_NUMGPS;
982 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
983 {
984 OLD_G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
985 G_GLONASS_IOD(co->Sat[i].IOD)
986 OLD_G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
987 OLD_G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
988 OLD_G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
989 OLD_G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
990 OLD_G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
991 OLD_G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
992 OLD_G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
993 OLD_G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
994 OLD_G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
995 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
996 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
997 }
998 break;
999 case OLDCOTYPE_GLONASSCLOCK:
1000 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
1001 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
1002 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
1003 OLD_G_RESERVED6
1004 OLD_G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
1005 if(co->ClockDataSupplied)
1006 return GCOBR_DATAMISMATCH;
1007 co->ClockDataSupplied = 1;
1008 for(i = CLOCKORBIT_NUMGPS;
1009 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
1010 {
1011 OLD_G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
1012 G_GLONASS_IOD(co->Sat[i].IOD)
1013 OLD_G_DELTA_A0(co->Sat[i].Clock.DeltaA0)
1014 OLD_G_DELTA_A1(co->Sat[i].Clock.DeltaA1)
1015 OLD_G_DELTA_A2(co->Sat[i].Clock.DeltaA2)
1016 }
1017 break;
1018 case OLDCOTYPE_GLONASSCOMBINED:
1019 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
1020 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)
1021 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
1022 OLD_G_RESERVED6
1023 OLD_G_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
1024 if(co->ClockDataSupplied || co->OrbitDataSupplied)
1025 return GCOBR_DATAMISMATCH;
1026 co->OrbitDataSupplied = 1;
1027 co->ClockDataSupplied = 1;
1028 for(i = CLOCKORBIT_NUMGPS;
1029 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)
1030 {
1031 OLD_G_GLONASS_SATELLITE_ID(co->Sat[i].ID)
1032 G_GLONASS_IOD(co->Sat[i].IOD)
1033 OLD_G_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
1034 OLD_G_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
1035 OLD_G_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
1036 OLD_G_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
1037 OLD_G_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
1038 OLD_G_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
1039 OLD_G_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
1040 OLD_G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
1041 OLD_G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
1042 G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
1043 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
1044 OLD_G_DELTA_A0(co->Sat[i].Clock.DeltaA0)
1045 OLD_G_DELTA_A1(co->Sat[i].Clock.DeltaA1)
1046 OLD_G_DELTA_A2(co->Sat[i].Clock.DeltaA2)
1047 }
1048 break;
1049 case OLDBTYPE_GPS:
1050 if(!b) return GCOBR_NOBIASPARAMETER;
1051 G_GPS_EPOCH_TIME(b->GPSEpochTime, co->NumberOfGPSSat)
1052 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
1053 OLD_G_RESERVED6
1054 OLD_G_NO_OF_SATELLITES(b->NumberOfGPSSat)
1055 for(i = 0; i < b->NumberOfGPSSat; ++i)
1056 {
1057 G_GPS_SATELLITE_ID(b->Sat[i].ID)
1058 G_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
1059 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
1060 {
1061 G_GPS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
1062 OLD_G_CODE_BIAS(b->Sat[i].Biases[j].Bias)
1063 }
1064 }
1065 break;
1066 case OLDBTYPE_GLONASS:
1067 if(!b) return GCOBR_NOBIASPARAMETER;
1068 G_GPS_EPOCH_TIME(b->GLONASSEpochTime, co->NumberOfGLONASSSat)
1069 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
1070 OLD_G_RESERVED6
1071 OLD_G_NO_OF_SATELLITES(b->NumberOfGLONASSSat)
1072 for(i = CLOCKORBIT_NUMGPS;
1073 i < CLOCKORBIT_NUMGPS+b->NumberOfGLONASSSat; ++i)
1074 {
1075 OLD_G_GLONASS_SATELLITE_ID(b->Sat[i].ID)
1076 G_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
1077 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
1078 {
1079 G_GLONASS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
1080 OLD_G_CODE_BIAS(b->Sat[i].Biases[j].Bias)
1081 }
1082 }
1083 break;
1084#endif
1085 default:
1086 return GCOBR_UNKNOWNTYPE;
1087 }
1088#ifdef DEBUG
1089for(type = 0; type < size && (unsigned char)buffer[type] != 0xD3; ++type)
1090 numbits += 8;
1091fprintf(stderr, "numbits left %d\n",numbits);
1092#endif
1093 if(bytesused)
1094 *bytesused = sizeofrtcmblock+6;
1095 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK;
1096}
1097#endif /* NODECODE */
Note: See TracBrowser for help on using the repository browser.