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