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

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

fixed

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