[297] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[297] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[297] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[297] | 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[296] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: RTCM3Decoder
|
---|
| 30 | *
|
---|
| 31 | * Purpose: RTCM3 Decoder
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Aug-2006
|
---|
| 36 | *
|
---|
[7753] | 37 | * Changes:
|
---|
[296] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
[1807] | 42 | #include <iomanip>
|
---|
| 43 | #include <sstream>
|
---|
[296] | 44 | #include <math.h>
|
---|
[585] | 45 | #include <string.h>
|
---|
[296] | 46 |
|
---|
[6812] | 47 | #include "bits.h"
|
---|
| 48 | #include "gnss.h"
|
---|
[296] | 49 | #include "RTCM3Decoder.h"
|
---|
[6812] | 50 | #include "rtcm_utils.h"
|
---|
[296] | 51 | #include "bncconst.h"
|
---|
[5070] | 52 | #include "bnccore.h"
|
---|
[1535] | 53 | #include "bncutils.h"
|
---|
[7753] | 54 | #include "bncsettings.h"
|
---|
[296] | 55 |
|
---|
| 56 | using namespace std;
|
---|
| 57 |
|
---|
[320] | 58 | // Error Handling
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
[504] | 60 | void RTCM3Error(const char*, ...) {
|
---|
[505] | 61 | }
|
---|
[320] | 62 |
|
---|
[296] | 63 | // Constructor
|
---|
| 64 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7753] | 65 | RTCM3Decoder::RTCM3Decoder(const QString& staID, bncRawFile* rawFile) :
|
---|
[8158] | 66 | GPSDecoder() {
|
---|
[505] | 67 |
|
---|
[8158] | 68 | _staID = staID;
|
---|
[2527] | 69 | _rawFile = rawFile;
|
---|
[2387] | 70 |
|
---|
[8158] | 71 | connect(this, SIGNAL(newGPSEph(t_ephGPS)), BNC_CORE,
|
---|
| 72 | SLOT(slotNewGPSEph(t_ephGPS)));
|
---|
| 73 | connect(this, SIGNAL(newGlonassEph(t_ephGlo)), BNC_CORE,
|
---|
| 74 | SLOT(slotNewGlonassEph(t_ephGlo)));
|
---|
| 75 | connect(this, SIGNAL(newGalileoEph(t_ephGal)), BNC_CORE,
|
---|
| 76 | SLOT(slotNewGalileoEph(t_ephGal)));
|
---|
| 77 | connect(this, SIGNAL(newSBASEph(t_ephSBAS)), BNC_CORE,
|
---|
| 78 | SLOT(slotNewSBASEph(t_ephSBAS)));
|
---|
| 79 | connect(this, SIGNAL(newBDSEph(t_ephBDS)), BNC_CORE,
|
---|
| 80 | SLOT(slotNewBDSEph(t_ephBDS)));
|
---|
[939] | 81 |
|
---|
[6812] | 82 | _MessageSize = _SkipBytes = _BlockSize = _NeedBytes = 0;
|
---|
[296] | 83 | }
|
---|
| 84 |
|
---|
| 85 | // Destructor
|
---|
| 86 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 87 | RTCM3Decoder::~RTCM3Decoder() {
|
---|
[3001] | 88 | QMapIterator<QByteArray, RTCM3coDecoder*> it(_coDecoders);
|
---|
[8158] | 89 | while (it.hasNext())
|
---|
[6812] | 90 | {
|
---|
[3008] | 91 | it.next();
|
---|
| 92 | delete it.value();
|
---|
[3001] | 93 | }
|
---|
[296] | 94 | }
|
---|
| 95 |
|
---|
[7753] | 96 | //
|
---|
[296] | 97 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 98 | bool RTCM3Decoder::DecodeRTCM3GPS(unsigned char* data, int size) {
|
---|
[6812] | 99 | bool decoded = false;
|
---|
| 100 | bncTime CurrentObsTime;
|
---|
| 101 | int i, numsats, syncf, type;
|
---|
| 102 | uint64_t numbits = 0, bitfield = 0;
|
---|
[508] | 103 |
|
---|
[6812] | 104 | data += 3; /* header */
|
---|
| 105 | size -= 6; /* header + crc */
|
---|
[1218] | 106 |
|
---|
[6812] | 107 | GETBITS(type, 12)
|
---|
[8158] | 108 | SKIPBITS(12)
|
---|
| 109 | /* id */
|
---|
| 110 | GETBITS(i, 30)
|
---|
[8159] | 111 |
|
---|
[8158] | 112 | CurrentObsTime.set(i);
|
---|
| 113 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 114 | decoded = true;
|
---|
[8164] | 115 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 116 | _CurrentObsList.clear();
|
---|
[2551] | 117 | }
|
---|
[7753] | 118 |
|
---|
[6812] | 119 | _CurrentTime = CurrentObsTime;
|
---|
[2551] | 120 |
|
---|
[8158] | 121 | GETBITS(syncf, 1)
|
---|
| 122 | /* sync */
|
---|
| 123 | GETBITS(numsats, 5)
|
---|
| 124 | SKIPBITS(4)
|
---|
| 125 | /* smind, smint */
|
---|
[3002] | 126 |
|
---|
[8158] | 127 | while (numsats--) {
|
---|
| 128 | int sv, code, l1range, amb = 0;
|
---|
[6812] | 129 | t_satObs CurrentObs;
|
---|
| 130 | CurrentObs._time = CurrentObsTime;
|
---|
| 131 |
|
---|
| 132 | GETBITS(sv, 6)
|
---|
[8158] | 133 | if (sv < 40)
|
---|
[6812] | 134 | CurrentObs._prn.set('G', sv);
|
---|
| 135 | else
|
---|
[8158] | 136 | CurrentObs._prn.set('S', sv - 20);
|
---|
[6812] | 137 |
|
---|
| 138 | t_frqObs *frqObs = new t_frqObs;
|
---|
| 139 | /* L1 */
|
---|
| 140 | GETBITS(code, 1);
|
---|
[8158] | 141 | (code) ?
|
---|
| 142 | frqObs->_rnxType2ch.assign("1W") : frqObs->_rnxType2ch.assign("1C");
|
---|
[6812] | 143 | GETBITS(l1range, 24);
|
---|
| 144 | GETBITSSIGN(i, 20);
|
---|
[8158] | 145 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 146 | frqObs->_code = l1range * 0.02;
|
---|
| 147 | frqObs->_phase = (l1range * 0.02 + i * 0.0005) / GPS_WAVELENGTH_L1;
|
---|
[6812] | 148 | frqObs->_codeValid = frqObs->_phaseValid = true;
|
---|
[3002] | 149 | }
|
---|
[9088] | 150 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 151 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8617] | 152 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 153 | if (type == 1002 || type == 1004) {
|
---|
| 154 | GETBITS(amb, 8);
|
---|
| 155 | if (amb) {
|
---|
| 156 | frqObs->_code += amb * 299792.458;
|
---|
| 157 | frqObs->_phase += (amb * 299792.458) / GPS_WAVELENGTH_L1;
|
---|
[1021] | 158 | }
|
---|
[6812] | 159 | GETBITS(i, 8);
|
---|
[8158] | 160 | if (i) {
|
---|
| 161 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 162 | frqObs->_snrValid = true;
|
---|
| 163 | }
|
---|
[1021] | 164 | }
|
---|
[6812] | 165 | CurrentObs._obs.push_back(frqObs);
|
---|
[8158] | 166 | if (type == 1003 || type == 1004) {
|
---|
[6812] | 167 | frqObs = new t_frqObs;
|
---|
| 168 | /* L2 */
|
---|
[8158] | 169 | GETBITS(code, 2);
|
---|
| 170 | switch (code) {
|
---|
| 171 | case 3:
|
---|
| 172 | frqObs->_rnxType2ch.assign("2W"); /* or "2Y"? */
|
---|
| 173 | break;
|
---|
| 174 | case 2:
|
---|
| 175 | frqObs->_rnxType2ch.assign("2W");
|
---|
| 176 | break;
|
---|
| 177 | case 1:
|
---|
| 178 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 179 | break;
|
---|
| 180 | case 0:
|
---|
| 181 | frqObs->_rnxType2ch.assign("2X"); /* or "2S" or "2L"? */
|
---|
| 182 | break;
|
---|
[6812] | 183 | }
|
---|
[8158] | 184 | GETBITSSIGN(i, 14);
|
---|
| 185 | if ((i & ((1 << 14) - 1)) != 0x2000) {
|
---|
| 186 | frqObs->_code = l1range * 0.02 + i * 0.02 + amb * 299792.458;
|
---|
[6812] | 187 | frqObs->_codeValid = true;
|
---|
| 188 | }
|
---|
[8158] | 189 | GETBITSSIGN(i, 20);
|
---|
| 190 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 191 | frqObs->_phase = (l1range * 0.02 + i * 0.0005 + amb * 299792.458)
|
---|
| 192 | / GPS_WAVELENGTH_L2;
|
---|
[6812] | 193 | frqObs->_phaseValid = true;
|
---|
| 194 | }
|
---|
[9088] | 195 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 196 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8682] | 197 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 198 | if (type == 1004) {
|
---|
[6812] | 199 | GETBITS(i, 8);
|
---|
[8158] | 200 | if (i) {
|
---|
| 201 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 202 | frqObs->_snrValid = true;
|
---|
| 203 | }
|
---|
| 204 | }
|
---|
| 205 | CurrentObs._obs.push_back(frqObs);
|
---|
| 206 | }
|
---|
| 207 | _CurrentObsList.push_back(CurrentObs);
|
---|
[913] | 208 | }
|
---|
[7753] | 209 |
|
---|
[8158] | 210 | if (!syncf) {
|
---|
[6812] | 211 | decoded = true;
|
---|
[7753] | 212 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 213 | _CurrentTime.reset();
|
---|
| 214 | _CurrentObsList.clear();
|
---|
[2527] | 215 | }
|
---|
[6812] | 216 | return decoded;
|
---|
| 217 | }
|
---|
[2527] | 218 |
|
---|
[6812] | 219 | #define RTCM3_MSM_NUMSIG 32
|
---|
| 220 | #define RTCM3_MSM_NUMSAT 64
|
---|
| 221 | #define RTCM3_MSM_NUMCELLS 96 /* arbitrary limit */
|
---|
[1127] | 222 |
|
---|
[6812] | 223 | /**
|
---|
| 224 | * Frequency numbers of GLONASS with an offset of 100 to detect unset values.
|
---|
| 225 | * Gets filled by ephemeris and data blocks and shared between different streams.
|
---|
| 226 | */
|
---|
| 227 | static int GLOFreq[RTCM3_MSM_NUMSAT];
|
---|
[1127] | 228 |
|
---|
[6812] | 229 | /*
|
---|
| 230 | * Storage structure to store frequency and RINEX ID assignment for MSM
|
---|
| 231 | * message */
|
---|
| 232 | struct CodeData {
|
---|
| 233 | double wl;
|
---|
| 234 | const char *code; /* currently unused */
|
---|
| 235 | };
|
---|
[2677] | 236 |
|
---|
[6812] | 237 | /** MSM signal types for GPS and SBAS */
|
---|
[8158] | 238 | static struct CodeData gps[RTCM3_MSM_NUMSIG] = {
|
---|
| 239 | {0.0, 0},
|
---|
| 240 | {GPS_WAVELENGTH_L1, "1C"},
|
---|
| 241 | {GPS_WAVELENGTH_L1, "1P"},
|
---|
| 242 | {GPS_WAVELENGTH_L1, "1W"},
|
---|
| 243 | {0.0, 0},
|
---|
| 244 | {0.0, 0},
|
---|
[8801] | 245 | {0.0, 0},
|
---|
[8158] | 246 | {GPS_WAVELENGTH_L2, "2C"},
|
---|
| 247 | {GPS_WAVELENGTH_L2, "2P"},
|
---|
| 248 | {GPS_WAVELENGTH_L2, "2W"},
|
---|
| 249 | {0.0, 0},
|
---|
| 250 | {0.0, 0},
|
---|
| 251 | {0.0, 0},
|
---|
[8801] | 252 | {0.0, 0},
|
---|
[8158] | 253 | {GPS_WAVELENGTH_L2, "2S"},
|
---|
| 254 | {GPS_WAVELENGTH_L2, "2L"},
|
---|
| 255 | {GPS_WAVELENGTH_L2, "2X"},
|
---|
| 256 | {0.0, 0},
|
---|
| 257 | {0.0, 0},
|
---|
| 258 | {0.0, 0},
|
---|
| 259 | {0.0, 0},
|
---|
| 260 | {GPS_WAVELENGTH_L5, "5I"},
|
---|
| 261 | {GPS_WAVELENGTH_L5, "5Q"},
|
---|
| 262 | {GPS_WAVELENGTH_L5, "5X"},
|
---|
| 263 | {0.0, 0},
|
---|
| 264 | {0.0, 0},
|
---|
| 265 | {0.0, 0},
|
---|
| 266 | {0.0, 0},
|
---|
| 267 | {0.0, 0},
|
---|
| 268 | {GPS_WAVELENGTH_L1, "1S"},
|
---|
| 269 | {GPS_WAVELENGTH_L1, "1L"},
|
---|
| 270 | {GPS_WAVELENGTH_L1, "1X"}
|
---|
| 271 | };
|
---|
[1185] | 272 |
|
---|
[6812] | 273 | /**
|
---|
| 274 | * MSM signal types for GLONASS
|
---|
[7753] | 275 | *
|
---|
[6812] | 276 | * NOTE: Uses 0.0, 1.0 for wavelength as sat index dependence is done later!
|
---|
| 277 | */
|
---|
[8158] | 278 | static struct CodeData glo[RTCM3_MSM_NUMSIG] = {
|
---|
| 279 | {0.0, 0},
|
---|
| 280 | {0.0, "1C"},
|
---|
| 281 | {0.0, "1P"},
|
---|
| 282 | {0.0, 0},
|
---|
| 283 | {0.0, 0},
|
---|
| 284 | {0.0, 0},
|
---|
| 285 | {0.0, 0},
|
---|
| 286 | {1.0, "2C"},
|
---|
| 287 | {1.0, "2P"},
|
---|
[8801] | 288 | {GLO_WAVELENGTH_L1a, "4A"},
|
---|
| 289 | {GLO_WAVELENGTH_L1a, "4B"},
|
---|
| 290 | {GLO_WAVELENGTH_L1a, "4X"},
|
---|
| 291 | {GLO_WAVELENGTH_L2a, "6A"},
|
---|
| 292 | {GLO_WAVELENGTH_L2a, "6B"},
|
---|
| 293 | {GLO_WAVELENGTH_L2a, "6X"},
|
---|
| 294 | {GLO_WAVELENGTH_L3, "3I"},
|
---|
| 295 | {GLO_WAVELENGTH_L3, "3Q"},
|
---|
| 296 | {GLO_WAVELENGTH_L3, "3X"},
|
---|
[8158] | 297 | {0.0, 0},
|
---|
| 298 | {0.0, 0},
|
---|
| 299 | {0.0, 0},
|
---|
| 300 | {0.0, 0},
|
---|
| 301 | {0.0, 0},
|
---|
| 302 | {0.0, 0},
|
---|
| 303 | {0.0, 0},
|
---|
| 304 | {0.0, 0},
|
---|
| 305 | {0.0, 0},
|
---|
| 306 | {0.0, 0},
|
---|
| 307 | {0.0, 0},
|
---|
| 308 | {0.0, 0},
|
---|
| 309 | {0.0, 0},
|
---|
| 310 | {0.0, 0}
|
---|
| 311 | };
|
---|
[1130] | 312 |
|
---|
[6812] | 313 | /** MSM signal types for Galileo */
|
---|
[8158] | 314 | static struct CodeData gal[RTCM3_MSM_NUMSIG] = {
|
---|
| 315 | {0.0, 0},
|
---|
[8801] | 316 | {GAL_WAVELENGTH_E1, "1C"},
|
---|
| 317 | {GAL_WAVELENGTH_E1, "1A"},
|
---|
| 318 | {GAL_WAVELENGTH_E1, "1B"},
|
---|
| 319 | {GAL_WAVELENGTH_E1, "1X"},
|
---|
| 320 | {GAL_WAVELENGTH_E1, "1Z"},
|
---|
[8158] | 321 | {0.0, 0},
|
---|
[8801] | 322 | {GAL_WAVELENGTH_E6, "6C"},
|
---|
| 323 | {GAL_WAVELENGTH_E6, "6A"},
|
---|
| 324 | {GAL_WAVELENGTH_E6, "6B"},
|
---|
| 325 | {GAL_WAVELENGTH_E6, "6X"},
|
---|
| 326 | {GAL_WAVELENGTH_E6, "6Z"},
|
---|
[8158] | 327 | {0.0, 0},
|
---|
| 328 | {GAL_WAVELENGTH_E5B, "7I"},
|
---|
| 329 | {GAL_WAVELENGTH_E5B, "7Q"},
|
---|
| 330 | {GAL_WAVELENGTH_E5B, "7X"},
|
---|
| 331 | {0.0, 0},
|
---|
[8801] | 332 | {GAL_WAVELENGTH_E5AB,"8I"},
|
---|
| 333 | {GAL_WAVELENGTH_E5AB,"8Q"},
|
---|
| 334 | {GAL_WAVELENGTH_E5AB,"8X"},
|
---|
[8158] | 335 | {0.0, 0},
|
---|
| 336 | {GAL_WAVELENGTH_E5A, "5I"},
|
---|
| 337 | {GAL_WAVELENGTH_E5A, "5Q"},
|
---|
| 338 | {GAL_WAVELENGTH_E5A, "5X"},
|
---|
| 339 | {0.0, 0},
|
---|
| 340 | {0.0, 0},
|
---|
| 341 | {0.0, 0},
|
---|
| 342 | {0.0, 0},
|
---|
| 343 | {0.0, 0},
|
---|
| 344 | {0.0, 0},
|
---|
| 345 | {0.0, 0},
|
---|
[8801] | 346 | {0.0, 0}
|
---|
[8158] | 347 | };
|
---|
[1185] | 348 |
|
---|
[6812] | 349 | /** MSM signal types for QZSS */
|
---|
[8158] | 350 | static struct CodeData qzss[RTCM3_MSM_NUMSIG] = {
|
---|
| 351 | {0.0, 0},
|
---|
| 352 | {GPS_WAVELENGTH_L1, "1C"},
|
---|
| 353 | {0.0, 0},
|
---|
| 354 | {0.0, 0},
|
---|
| 355 | {0.0, 0},
|
---|
| 356 | {0.0, 0},
|
---|
| 357 | {0.0, 0},
|
---|
[8844] | 358 | {0.0, 0},
|
---|
[8682] | 359 | {QZSS_WAVELENGTH_L6, "6S"},
|
---|
| 360 | {QZSS_WAVELENGTH_L6, "6L"},
|
---|
| 361 | {QZSS_WAVELENGTH_L6, "6X"},
|
---|
[8158] | 362 | {0.0, 0},
|
---|
| 363 | {0.0, 0},
|
---|
| 364 | {0.0, 0},
|
---|
| 365 | {GPS_WAVELENGTH_L2, "2S"},
|
---|
| 366 | {GPS_WAVELENGTH_L2, "2L"},
|
---|
| 367 | {GPS_WAVELENGTH_L2, "2X"},
|
---|
| 368 | {0.0, 0},
|
---|
| 369 | {0.0, 0},
|
---|
| 370 | {0.0, 0},
|
---|
| 371 | {0.0, 0},
|
---|
| 372 | {GPS_WAVELENGTH_L5, "5I"},
|
---|
| 373 | {GPS_WAVELENGTH_L5, "5Q"},
|
---|
| 374 | {GPS_WAVELENGTH_L5, "5X"},
|
---|
| 375 | {0.0, 0},
|
---|
| 376 | {0.0, 0},
|
---|
| 377 | {0.0, 0},
|
---|
| 378 | {0.0, 0},
|
---|
| 379 | {0.0, 0},
|
---|
[8682] | 380 | {GPS_WAVELENGTH_L1, "1S"},
|
---|
| 381 | {GPS_WAVELENGTH_L1, "1L"},
|
---|
[8158] | 382 | {GPS_WAVELENGTH_L1, "1X"}
|
---|
| 383 | };
|
---|
[1185] | 384 |
|
---|
[6812] | 385 | /** MSM signal types for Beidou/BDS */
|
---|
[8158] | 386 | static struct CodeData bds[RTCM3_MSM_NUMSIG] = {
|
---|
| 387 | {0.0, 0},
|
---|
| 388 | {BDS_WAVELENGTH_B1, "2I"},
|
---|
[8682] | 389 | {BDS_WAVELENGTH_B1, "2Q"},
|
---|
| 390 | {BDS_WAVELENGTH_B1, "2X"},
|
---|
[8158] | 391 | {0.0, 0},
|
---|
| 392 | {0.0, 0},
|
---|
| 393 | {0.0, 0},
|
---|
| 394 | {BDS_WAVELENGTH_B3, "6I"},
|
---|
[8682] | 395 | {BDS_WAVELENGTH_B3, "6Q"},
|
---|
| 396 | {BDS_WAVELENGTH_B3, "6X"},
|
---|
[8158] | 397 | {0.0, 0},
|
---|
| 398 | {0.0, 0},
|
---|
| 399 | {0.0, 0},
|
---|
| 400 | {BDS_WAVELENGTH_B2, "7I"},
|
---|
[8682] | 401 | {BDS_WAVELENGTH_B2, "7Q"},
|
---|
| 402 | {BDS_WAVELENGTH_B2, "7X"},
|
---|
[8158] | 403 | {0.0, 0},
|
---|
| 404 | {0.0, 0},
|
---|
| 405 | {0.0, 0},
|
---|
| 406 | {0.0, 0},
|
---|
| 407 | {0.0, 0},
|
---|
[8801] | 408 | {BDS_WAVELENGTH_B2a, "5D"},
|
---|
| 409 | {BDS_WAVELENGTH_B2a, "5P"},
|
---|
| 410 | {BDS_WAVELENGTH_B2a, "5X"},
|
---|
[9000] | 411 | {BDS_WAVELENGTH_B2b, "7D"},
|
---|
[8158] | 412 | {0.0, 0},
|
---|
| 413 | {0.0, 0},
|
---|
| 414 | {0.0, 0},
|
---|
| 415 | {0.0, 0},
|
---|
[8818] | 416 | {BDS_WAVELENGTH_B1C, "1D"},
|
---|
| 417 | {BDS_WAVELENGTH_B1C, "1P"},
|
---|
| 418 | {BDS_WAVELENGTH_B1C, "1X"}
|
---|
[8158] | 419 | };
|
---|
[1807] | 420 |
|
---|
[8844] | 421 | /** MSM signal types for IRNSS */
|
---|
[8783] | 422 | static struct CodeData irn[RTCM3_MSM_NUMSIG] = {
|
---|
| 423 | {0.0, 0},
|
---|
| 424 | {0.0, 0},
|
---|
| 425 | {0.0, 0},
|
---|
| 426 | {0.0, 0},
|
---|
| 427 | {0.0, 0},
|
---|
| 428 | {0.0, 0},
|
---|
| 429 | {0.0, 0},
|
---|
| 430 | {IRNSS_WAVELENGTH_S, "9A"},
|
---|
| 431 | {0.0, 0},
|
---|
| 432 | {0.0, 0},
|
---|
| 433 | {0.0, 0},
|
---|
| 434 | {0.0, 0},
|
---|
| 435 | {0.0, 0},
|
---|
| 436 | {0.0, 0},
|
---|
| 437 | {0.0, 0},
|
---|
| 438 | {0.0, 0},
|
---|
| 439 | {0.0, 0},
|
---|
| 440 | {0.0, 0},
|
---|
| 441 | {0.0, 0},
|
---|
| 442 | {0.0, 0},
|
---|
| 443 | {0.0, 0},
|
---|
| 444 | {IRNSS_WAVELENGTH_L5, "5A"},
|
---|
| 445 | {0.0, 0},
|
---|
| 446 | {0.0, 0},
|
---|
| 447 | {0.0, 0},
|
---|
| 448 | {0.0, 0},
|
---|
| 449 | {0.0, 0},
|
---|
| 450 | {0.0, 0},
|
---|
| 451 | {0.0, 0},
|
---|
| 452 | {0.0, 0},
|
---|
| 453 | {0.0, 0},
|
---|
| 454 | {0.0, 0}
|
---|
| 455 | };
|
---|
| 456 |
|
---|
[6812] | 457 | #define UINT64(c) c ## ULL
|
---|
[1033] | 458 |
|
---|
[7753] | 459 | //
|
---|
[6812] | 460 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8801] | 461 | bool RTCM3Decoder::DecodeRTCM3MSM(unsigned char* data, int size) {
|
---|
[6812] | 462 | bool decoded = false;
|
---|
| 463 | int type, syncf, i;
|
---|
| 464 | uint64_t numbits = 0, bitfield = 0;
|
---|
[1807] | 465 |
|
---|
[6812] | 466 | data += 3; /* header */
|
---|
| 467 | size -= 6; /* header + crc */
|
---|
[1239] | 468 |
|
---|
[6812] | 469 | GETBITS(type, 12)
|
---|
[8158] | 470 | SKIPBITS(12)
|
---|
| 471 | /* id */
|
---|
[6812] | 472 | char sys;
|
---|
[9007] | 473 | if (type >= 1131)
|
---|
| 474 | sys = 'I';
|
---|
| 475 | else if (type >= 1121)
|
---|
[6812] | 476 | sys = 'C';
|
---|
[8158] | 477 | else if (type >= 1111)
|
---|
[6812] | 478 | sys = 'J';
|
---|
[8158] | 479 | else if (type >= 1101)
|
---|
[6812] | 480 | sys = 'S';
|
---|
[8158] | 481 | else if (type >= 1091)
|
---|
[6812] | 482 | sys = 'E';
|
---|
[8158] | 483 | else if (type >= 1081)
|
---|
[6812] | 484 | sys = 'R';
|
---|
[8783] | 485 | else if (type >= 1071)
|
---|
[6812] | 486 | sys = 'G';
|
---|
[2683] | 487 |
|
---|
[6812] | 488 | bncTime CurrentObsTime;
|
---|
[8783] | 489 | if (sys == 'C') /* BDS */ {
|
---|
[8158] | 490 | GETBITS(i, 30)
|
---|
[6812] | 491 | CurrentObsTime.setBDS(i);
|
---|
| 492 | }
|
---|
[8158] | 493 | else if (sys == 'R') /* GLONASS */ {
|
---|
[6812] | 494 | SKIPBITS(3)
|
---|
[8158] | 495 | GETBITS(i, 27)
|
---|
| 496 | /* tk */
|
---|
[6812] | 497 | CurrentObsTime.setTk(i);
|
---|
| 498 | }
|
---|
[8158] | 499 | else /* GPS style date */ {
|
---|
| 500 | GETBITS(i, 30)
|
---|
[6812] | 501 | CurrentObsTime.set(i);
|
---|
| 502 | }
|
---|
[8158] | 503 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 504 | decoded = true;
|
---|
[8160] | 505 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 506 | _CurrentObsList.clear();
|
---|
| 507 | }
|
---|
| 508 | _CurrentTime = CurrentObsTime;
|
---|
[2677] | 509 |
|
---|
[6812] | 510 | GETBITS(syncf, 1)
|
---|
| 511 | /**
|
---|
| 512 | * Ignore unknown types except for sync flag
|
---|
[7753] | 513 | *
|
---|
[6812] | 514 | * We actually support types 1-3 in following code, but as they are missing
|
---|
| 515 | * the full cycles and can't be used later we skip interpretation here already.
|
---|
| 516 | */
|
---|
[9007] | 517 | if (type <= 1137 && (type % 10) >= 4 && (type % 10) <= 7) {
|
---|
[6812] | 518 | int sigmask, numsat = 0, numsig = 0;
|
---|
| 519 | uint64_t satmask, cellmask, ui;
|
---|
[8801] | 520 | // satellite data
|
---|
| 521 | double rrmod[RTCM3_MSM_NUMSAT]; // GNSS sat rough ranges modulo 1 millisecond
|
---|
| 522 | int rrint[RTCM3_MSM_NUMSAT]; // number of integer msecs in GNSS sat rough ranges
|
---|
| 523 | int rdop[RTCM3_MSM_NUMSAT]; // GNSS sat rough phase range rates
|
---|
| 524 | int extsat[RTCM3_MSM_NUMSAT];// extended sat info
|
---|
| 525 | // signal data
|
---|
| 526 | int ll[RTCM3_MSM_NUMCELLS]; // lock time indicator
|
---|
| 527 | /*int hc[RTCM3_MSM_NUMCELLS];*/ // half cycle ambiguity indicator
|
---|
| 528 | double cnr[RTCM3_MSM_NUMCELLS]; // signal cnr
|
---|
| 529 | double cp[RTCM3_MSM_NUMCELLS]; // fine phase range data
|
---|
| 530 | double psr[RTCM3_MSM_NUMCELLS]; // fine psr
|
---|
| 531 | double dop[RTCM3_MSM_NUMCELLS]; // fine phase range rates
|
---|
[2674] | 532 |
|
---|
[8158] | 533 | SKIPBITS(3 + 7 + 2 + 2 + 1 + 3)
|
---|
[6812] | 534 | GETBITS64(satmask, RTCM3_MSM_NUMSAT)
|
---|
[2674] | 535 |
|
---|
[6812] | 536 | /* http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ */
|
---|
[8158] | 537 | for (ui = satmask; ui; ui &= (ui - 1) /* remove rightmost bit */)
|
---|
[6812] | 538 | ++numsat;
|
---|
| 539 | GETBITS(sigmask, RTCM3_MSM_NUMSIG)
|
---|
[8158] | 540 | for (i = sigmask; i; i &= (i - 1) /* remove rightmost bit */)
|
---|
[6812] | 541 | ++numsig;
|
---|
[8158] | 542 | for (i = 0; i < RTCM3_MSM_NUMSAT; ++i)
|
---|
[6812] | 543 | extsat[i] = 15;
|
---|
[2674] | 544 |
|
---|
[8158] | 545 | i = numsat * numsig;
|
---|
| 546 | GETBITS64(cellmask, (unsigned )i)
|
---|
[8801] | 547 | // satellite data
|
---|
[8158] | 548 | switch (type % 10) {
|
---|
[6812] | 549 | case 1:
|
---|
| 550 | case 2:
|
---|
| 551 | case 3:
|
---|
[8158] | 552 | /* partial data, already skipped above, but implemented for future expansion ! */
|
---|
| 553 | for (int j = numsat; j--;)
|
---|
| 554 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
[6812] | 555 | break;
|
---|
| 556 | case 4:
|
---|
[8158] | 557 | case 6:
|
---|
| 558 | for (int j = numsat; j--;)
|
---|
| 559 | GETBITS(rrint[j], 8)
|
---|
| 560 | for (int j = numsat; j--;)
|
---|
| 561 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
[6812] | 562 | break;
|
---|
| 563 | case 5:
|
---|
| 564 | case 7:
|
---|
[8158] | 565 | for (int j = numsat; j--;)
|
---|
| 566 | GETBITS(rrint[j], 8)
|
---|
| 567 | for (int j = numsat; j--;)
|
---|
| 568 | GETBITS(extsat[j], 4)
|
---|
| 569 | for (int j = numsat; j--;)
|
---|
| 570 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
| 571 | for (int j = numsat; j--;)
|
---|
| 572 | GETBITSSIGN(rdop[j], 14)
|
---|
[6812] | 573 | break;
|
---|
[8158] | 574 | }
|
---|
[8801] | 575 | // signal data
|
---|
[8158] | 576 | int numcells = numsat * numsig;
|
---|
| 577 | /** Drop anything which exceeds our cell limit. Increase limit definition
|
---|
| 578 | * when that happens. */
|
---|
| 579 | if (numcells <= RTCM3_MSM_NUMCELLS) {
|
---|
| 580 | switch (type % 10) {
|
---|
| 581 | case 1:
|
---|
| 582 | for (int count = numcells; count--;)
|
---|
| 583 | if (cellmask & (UINT64(1) << count))
|
---|
| 584 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 585 | break;
|
---|
| 586 | case 2:
|
---|
| 587 | for (int count = numcells; count--;)
|
---|
| 588 | if (cellmask & (UINT64(1) << count))
|
---|
| 589 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 590 | for (int count = numcells; count--;)
|
---|
| 591 | if (cellmask & (UINT64(1) << count))
|
---|
| 592 | GETBITS(ll[count], 4)
|
---|
| 593 | for (int count = numcells; count--;)
|
---|
| 594 | if (cellmask & (UINT64(1) << count))
|
---|
| 595 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 596 | break;
|
---|
| 597 | case 3:
|
---|
| 598 | for (int count = numcells; count--;)
|
---|
| 599 | if (cellmask & (UINT64(1) << count))
|
---|
| 600 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 601 | for (int count = numcells; count--;)
|
---|
| 602 | if (cellmask & (UINT64(1) << count))
|
---|
| 603 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 604 | for (int count = numcells; count--;)
|
---|
| 605 | if (cellmask & (UINT64(1) << count))
|
---|
| 606 | GETBITS(ll[count], 4)
|
---|
| 607 | for (int count = numcells; count--;)
|
---|
| 608 | if (cellmask & (UINT64(1) << count))
|
---|
| 609 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 610 | break;
|
---|
| 611 | case 4:
|
---|
| 612 | for (int count = numcells; count--;)
|
---|
| 613 | if (cellmask & (UINT64(1) << count))
|
---|
| 614 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 615 | for (int count = numcells; count--;)
|
---|
| 616 | if (cellmask & (UINT64(1) << count))
|
---|
| 617 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 618 | for (int count = numcells; count--;)
|
---|
| 619 | if (cellmask & (UINT64(1) << count))
|
---|
| 620 | GETBITS(ll[count], 4)
|
---|
| 621 | for (int count = numcells; count--;)
|
---|
| 622 | if (cellmask & (UINT64(1) << count))
|
---|
| 623 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 624 | for (int count = numcells; count--;)
|
---|
| 625 | if (cellmask & (UINT64(1) << count))
|
---|
| 626 | GETBITS(cnr[count], 6)
|
---|
| 627 | break;
|
---|
| 628 | case 5:
|
---|
| 629 | for (int count = numcells; count--;)
|
---|
| 630 | if (cellmask & (UINT64(1) << count))
|
---|
| 631 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 632 | for (int count = numcells; count--;)
|
---|
| 633 | if (cellmask & (UINT64(1) << count))
|
---|
| 634 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 635 | for (int count = numcells; count--;)
|
---|
| 636 | if (cellmask & (UINT64(1) << count))
|
---|
| 637 | GETBITS(ll[count], 4)
|
---|
| 638 | for (int count = numcells; count--;)
|
---|
| 639 | if (cellmask & (UINT64(1) << count))
|
---|
| 640 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 641 | for (int count = numcells; count--;)
|
---|
| 642 | if (cellmask & (UINT64(1) << count))
|
---|
| 643 | GETFLOAT(cnr[count], 6, 1.0)
|
---|
| 644 | for (int count = numcells; count--;)
|
---|
| 645 | if (cellmask & (UINT64(1) << count))
|
---|
| 646 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 647 | break;
|
---|
| 648 | case 6:
|
---|
| 649 | for (int count = numcells; count--;)
|
---|
| 650 | if (cellmask & (UINT64(1) << count))
|
---|
| 651 | GETFLOATSIGN(psr[count], 20, 1.0 / (1 << 29))
|
---|
| 652 | for (int count = numcells; count--;)
|
---|
| 653 | if (cellmask & (UINT64(1) << count))
|
---|
| 654 | GETFLOATSIGN(cp[count], 24, 1.0 / (1U << 31))
|
---|
| 655 | for (int count = numcells; count--;)
|
---|
| 656 | if (cellmask & (UINT64(1) << count))
|
---|
| 657 | GETBITS(ll[count], 10)
|
---|
| 658 | for (int count = numcells; count--;)
|
---|
| 659 | if (cellmask & (UINT64(1) << count))
|
---|
| 660 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 661 | for (int count = numcells; count--;)
|
---|
| 662 | if (cellmask & (UINT64(1) << count))
|
---|
| 663 | GETFLOAT(cnr[count], 10, 1.0 / (1 << 4))
|
---|
| 664 | break;
|
---|
| 665 | case 7:
|
---|
| 666 | for (int count = numcells; count--;)
|
---|
| 667 | if (cellmask & (UINT64(1) << count))
|
---|
| 668 | GETFLOATSIGN(psr[count], 20, 1.0 / (1 << 29))
|
---|
| 669 | for (int count = numcells; count--;)
|
---|
| 670 | if (cellmask & (UINT64(1) << count))
|
---|
| 671 | GETFLOATSIGN(cp[count], 24, 1.0 / (1U << 31))
|
---|
| 672 | for (int count = numcells; count--;)
|
---|
| 673 | if (cellmask & (UINT64(1) << count))
|
---|
| 674 | GETBITS(ll[count], 10)
|
---|
| 675 | for (int count = numcells; count--;)
|
---|
| 676 | if (cellmask & (UINT64(1) << count))
|
---|
| 677 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 678 | for (int count = numcells; count--;)
|
---|
| 679 | if (cellmask & (UINT64(1) << count))
|
---|
| 680 | GETFLOAT(cnr[count], 10, 1.0 / (1 << 4))
|
---|
| 681 | for (int count = numcells; count--;)
|
---|
| 682 | if (cellmask & (UINT64(1) << count))
|
---|
| 683 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 684 | break;
|
---|
[6812] | 685 | }
|
---|
| 686 | i = RTCM3_MSM_NUMSAT;
|
---|
| 687 | int j = -1;
|
---|
| 688 | t_satObs CurrentObs;
|
---|
[8158] | 689 | for (int count = numcells; count--;) {
|
---|
| 690 | while (j >= 0 && !(sigmask & (1 << --j)))
|
---|
[6812] | 691 | ;
|
---|
[8158] | 692 | if (j < 0) {
|
---|
| 693 | while (!(satmask & (UINT64(1) << (--i))))
|
---|
| 694 | /* next satellite */
|
---|
[6812] | 695 | ;
|
---|
[8158] | 696 | if (CurrentObs._obs.size() > 0)
|
---|
[6812] | 697 | _CurrentObsList.push_back(CurrentObs);
|
---|
| 698 | CurrentObs.clear();
|
---|
| 699 | CurrentObs._time = CurrentObsTime;
|
---|
[8158] | 700 | if (sys == 'S')
|
---|
| 701 | CurrentObs._prn.set(sys, 20 - 1 + RTCM3_MSM_NUMSAT - i);
|
---|
[6812] | 702 | else
|
---|
[8158] | 703 | CurrentObs._prn.set(sys, RTCM3_MSM_NUMSAT - i);
|
---|
[6812] | 704 | j = RTCM3_MSM_NUMSIG;
|
---|
[8158] | 705 | while (!(sigmask & (1 << --j)))
|
---|
[6812] | 706 | ;
|
---|
| 707 | --numsat;
|
---|
| 708 | }
|
---|
[8158] | 709 | if (cellmask & (UINT64(1) << count)) {
|
---|
| 710 | struct CodeData cd = {0.0, 0};
|
---|
| 711 | switch (sys) {
|
---|
| 712 | case 'J':
|
---|
| 713 | cd = qzss[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 714 | break;
|
---|
| 715 | case 'C':
|
---|
| 716 | cd = bds[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 717 | break;
|
---|
| 718 | case 'G':
|
---|
| 719 | case 'S':
|
---|
| 720 | cd = gps[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 721 | break;
|
---|
| 722 | case 'R':
|
---|
| 723 | cd = glo[RTCM3_MSM_NUMSIG - j - 1];
|
---|
[6812] | 724 | {
|
---|
[8158] | 725 | int k = GLOFreq[RTCM3_MSM_NUMSAT - i - 1];
|
---|
[8801] | 726 | if (extsat[numsat] < 14) { // channel number is available as extended info for MSM5/7
|
---|
| 727 | k = GLOFreq[RTCM3_MSM_NUMSAT - i - 1] = 100 + extsat[numsat] - 7;
|
---|
[8158] | 728 | }
|
---|
[8801] | 729 | if (k) {
|
---|
| 730 | if (cd.wl == 0.0) {
|
---|
| 731 | cd.wl = GLO_WAVELENGTH_L1(k - 100);
|
---|
| 732 | }
|
---|
| 733 | else if (cd.wl == 1.0) {
|
---|
| 734 | cd.wl = GLO_WAVELENGTH_L2(k - 100);
|
---|
| 735 | }
|
---|
| 736 | }
|
---|
| 737 | else if (!k && cd.wl <= 1) {
|
---|
[8158] | 738 | cd.code = 0;
|
---|
[8801] | 739 | }
|
---|
[2676] | 740 | }
|
---|
[8158] | 741 | break;
|
---|
| 742 | case 'E':
|
---|
| 743 | cd = gal[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 744 | break;
|
---|
[8783] | 745 | case 'I':
|
---|
| 746 | cd = irn[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 747 | break;
|
---|
[6812] | 748 | }
|
---|
[8158] | 749 | if (cd.code) {
|
---|
[6812] | 750 | t_frqObs *frqObs = new t_frqObs;
|
---|
[7850] | 751 | frqObs->_rnxType2ch.assign(cd.code);
|
---|
[2674] | 752 |
|
---|
[8158] | 753 | switch (type % 10) {
|
---|
| 754 | case 1:
|
---|
| 755 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 756 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 757 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 758 | frqObs->_codeValid = true;
|
---|
| 759 | }
|
---|
| 760 | break;
|
---|
| 761 | case 2:
|
---|
| 762 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 763 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 764 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 765 | frqObs->_phaseValid = true;
|
---|
[8617] | 766 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 767 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 768 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 769 | }
|
---|
| 770 | break;
|
---|
| 771 | case 3:
|
---|
| 772 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 773 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 774 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 775 | frqObs->_codeValid = true;
|
---|
| 776 | }
|
---|
| 777 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 778 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 779 | + rrmod[numsat] * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 780 | frqObs->_phaseValid = true;
|
---|
[8617] | 781 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 782 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 783 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 784 | }
|
---|
| 785 | break;
|
---|
| 786 | case 4:
|
---|
| 787 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 788 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 789 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 790 | frqObs->_codeValid = true;
|
---|
| 791 | }
|
---|
| 792 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 793 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 794 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 795 | frqObs->_phaseValid = true;
|
---|
[8617] | 796 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 797 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 798 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 799 | }
|
---|
| 800 | frqObs->_snr = cnr[count];
|
---|
| 801 | frqObs->_snrValid = true;
|
---|
| 802 | break;
|
---|
| 803 | case 5:
|
---|
| 804 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 805 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 806 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 807 | frqObs->_codeValid = true;
|
---|
| 808 | }
|
---|
| 809 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 810 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 811 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 812 | frqObs->_phaseValid = true;
|
---|
[8617] | 813 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 814 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 815 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 816 | }
|
---|
| 817 | frqObs->_snr = cnr[count];
|
---|
| 818 | frqObs->_snrValid = true;
|
---|
| 819 | if (dop[count] > -1.6384) {
|
---|
| 820 | frqObs->_doppler = -(dop[count] + rdop[numsat]) / cd.wl;
|
---|
| 821 | frqObs->_dopplerValid = true;
|
---|
| 822 | }
|
---|
| 823 | break;
|
---|
| 824 | case 6:
|
---|
| 825 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 826 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 827 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 828 | frqObs->_codeValid = true;
|
---|
| 829 | }
|
---|
| 830 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 831 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 832 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 833 | frqObs->_phaseValid = true;
|
---|
[8617] | 834 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 835 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 836 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 837 | }
|
---|
[6812] | 838 |
|
---|
[8158] | 839 | frqObs->_snr = cnr[count];
|
---|
| 840 | frqObs->_snrValid = true;
|
---|
| 841 | break;
|
---|
| 842 | case 7:
|
---|
| 843 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 844 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 845 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 846 | frqObs->_codeValid = true;
|
---|
| 847 | }
|
---|
| 848 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 849 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 850 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 851 | frqObs->_phaseValid = true;
|
---|
[8617] | 852 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 853 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 854 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 855 | }
|
---|
[6137] | 856 |
|
---|
[8158] | 857 | frqObs->_snr = cnr[count];
|
---|
| 858 | frqObs->_snrValid = true;
|
---|
[6137] | 859 |
|
---|
[8158] | 860 | if (dop[count] > -1.6384) {
|
---|
| 861 | frqObs->_doppler = -(dop[count] + rdop[numsat]) / cd.wl;
|
---|
| 862 | frqObs->_dopplerValid = true;
|
---|
| 863 | }
|
---|
| 864 | break;
|
---|
[366] | 865 | }
|
---|
[6812] | 866 | CurrentObs._obs.push_back(frqObs);
|
---|
[296] | 867 | }
|
---|
[6812] | 868 | }
|
---|
| 869 | }
|
---|
[8801] | 870 | if (CurrentObs._obs.size() > 0) {
|
---|
[6812] | 871 | _CurrentObsList.push_back(CurrentObs);
|
---|
[8801] | 872 | }
|
---|
[6812] | 873 | }
|
---|
| 874 | }
|
---|
[8937] | 875 | else if ((type % 10) < 4) {
|
---|
[6812] | 876 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
[8204] | 877 | .arg(_staID).arg(type).toLatin1(), true));
|
---|
[6812] | 878 | }
|
---|
[8158] | 879 | if (!syncf) {
|
---|
[6812] | 880 | decoded = true;
|
---|
[8166] | 881 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 882 | _CurrentTime.reset();
|
---|
| 883 | _CurrentObsList.clear();
|
---|
| 884 | }
|
---|
| 885 | return decoded;
|
---|
| 886 | }
|
---|
| 887 |
|
---|
[7753] | 888 | //
|
---|
[6812] | 889 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 890 | bool RTCM3Decoder::DecodeRTCM3GLONASS(unsigned char* data, int size) {
|
---|
[6812] | 891 | bool decoded = false;
|
---|
| 892 | bncTime CurrentObsTime;
|
---|
| 893 | int i, numsats, syncf, type;
|
---|
| 894 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 895 |
|
---|
| 896 | data += 3; /* header */
|
---|
| 897 | size -= 6; /* header + crc */
|
---|
| 898 |
|
---|
| 899 | GETBITS(type, 12)
|
---|
[8158] | 900 | SKIPBITS(12)
|
---|
| 901 | /* id */
|
---|
| 902 | GETBITS(i, 27)
|
---|
| 903 | /* tk */
|
---|
[6812] | 904 |
|
---|
| 905 | CurrentObsTime.setTk(i);
|
---|
[8158] | 906 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 907 | decoded = true;
|
---|
[7753] | 908 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 909 | _CurrentObsList.clear();
|
---|
| 910 | }
|
---|
| 911 | _CurrentTime = CurrentObsTime;
|
---|
| 912 |
|
---|
[8158] | 913 | GETBITS(syncf, 1)
|
---|
| 914 | /* sync */
|
---|
| 915 | GETBITS(numsats, 5)
|
---|
| 916 | SKIPBITS(4)
|
---|
| 917 | /* smind, smint */
|
---|
[6812] | 918 |
|
---|
[8158] | 919 | while (numsats--) {
|
---|
| 920 | int sv, code, l1range, amb = 0, freq;
|
---|
[6812] | 921 | t_satObs CurrentObs;
|
---|
| 922 | CurrentObs._time = CurrentObsTime;
|
---|
| 923 |
|
---|
| 924 | GETBITS(sv, 6)
|
---|
| 925 | CurrentObs._prn.set('R', sv);
|
---|
| 926 | GETBITS(code, 1)
|
---|
| 927 | GETBITS(freq, 5)
|
---|
[8158] | 928 | GLOFreq[sv - 1] = 100 + freq - 7; /* store frequency for other users (MSM) */
|
---|
[6812] | 929 |
|
---|
| 930 | t_frqObs *frqObs = new t_frqObs;
|
---|
| 931 | /* L1 */
|
---|
[8158] | 932 | (code) ?
|
---|
| 933 | frqObs->_rnxType2ch.assign("1P") : frqObs->_rnxType2ch.assign("1C");
|
---|
[6812] | 934 | GETBITS(l1range, 25);
|
---|
| 935 | GETBITSSIGN(i, 20);
|
---|
[8158] | 936 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 937 | frqObs->_code = l1range * 0.02;
|
---|
[9088] | 938 | frqObs->_phase = (l1range * 0.02 + i * 0.0005) / GLO_WAVELENGTH_L1(freq - 7);
|
---|
[6812] | 939 | frqObs->_codeValid = frqObs->_phaseValid = true;
|
---|
| 940 | }
|
---|
[9088] | 941 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 942 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8682] | 943 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 944 | if (type == 1010 || type == 1012) {
|
---|
| 945 | GETBITS(amb, 7);
|
---|
| 946 | if (amb) {
|
---|
| 947 | frqObs->_code += amb * 599584.916;
|
---|
| 948 | frqObs->_phase += (amb * 599584.916) / GLO_WAVELENGTH_L1(freq - 7);
|
---|
[6812] | 949 | }
|
---|
| 950 | GETBITS(i, 8);
|
---|
[8158] | 951 | if (i) {
|
---|
| 952 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 953 | frqObs->_snrValid = true;
|
---|
| 954 | }
|
---|
| 955 | }
|
---|
| 956 | CurrentObs._obs.push_back(frqObs);
|
---|
[8158] | 957 | if (type == 1011 || type == 1012) {
|
---|
[6812] | 958 | frqObs = new t_frqObs;
|
---|
| 959 | /* L2 */
|
---|
[8158] | 960 | GETBITS(code, 2);
|
---|
| 961 | switch (code) {
|
---|
| 962 | case 3:
|
---|
| 963 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 964 | break;
|
---|
| 965 | case 2:
|
---|
| 966 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 967 | break;
|
---|
| 968 | case 1:
|
---|
| 969 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 970 | break;
|
---|
| 971 | case 0:
|
---|
| 972 | frqObs->_rnxType2ch.assign("2C");
|
---|
| 973 | break;
|
---|
[6812] | 974 | }
|
---|
[8158] | 975 | GETBITSSIGN(i, 14);
|
---|
| 976 | if ((i & ((1 << 14) - 1)) != 0x2000) {
|
---|
| 977 | frqObs->_code = l1range * 0.02 + i * 0.02 + amb * 599584.916;
|
---|
[6812] | 978 | frqObs->_codeValid = true;
|
---|
| 979 | }
|
---|
[8158] | 980 | GETBITSSIGN(i, 20);
|
---|
| 981 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 982 | frqObs->_phase = (l1range * 0.02 + i * 0.0005 + amb * 599584.916)
|
---|
| 983 | / GLO_WAVELENGTH_L2(freq - 7);
|
---|
[6812] | 984 | frqObs->_phaseValid = true;
|
---|
| 985 | }
|
---|
[9088] | 986 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 987 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8682] | 988 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 989 | if (type == 1012) {
|
---|
[6812] | 990 | GETBITS(i, 8);
|
---|
[8158] | 991 | if (i) {
|
---|
| 992 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 993 | frqObs->_snrValid = true;
|
---|
| 994 | }
|
---|
| 995 | }
|
---|
| 996 | CurrentObs._obs.push_back(frqObs);
|
---|
| 997 | }
|
---|
| 998 | _CurrentObsList.push_back(CurrentObs);
|
---|
| 999 | }
|
---|
[8158] | 1000 | if (!syncf) {
|
---|
[6812] | 1001 | decoded = true;
|
---|
[7753] | 1002 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 1003 | _CurrentTime.reset();
|
---|
| 1004 | _CurrentObsList.clear();
|
---|
| 1005 | }
|
---|
| 1006 | return decoded;
|
---|
| 1007 | }
|
---|
| 1008 |
|
---|
| 1009 | //
|
---|
| 1010 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1011 | bool RTCM3Decoder::DecodeGPSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1012 | bool decoded = false;
|
---|
| 1013 |
|
---|
[8158] | 1014 | if (size == 67) {
|
---|
[6812] | 1015 | t_ephGPS eph;
|
---|
| 1016 | int i, week;
|
---|
| 1017 | uint64_t numbits = 0, bitfield = 0;
|
---|
[8852] | 1018 | int fitIntervalFalg = 0;
|
---|
[6812] | 1019 |
|
---|
| 1020 | data += 3; /* header */
|
---|
| 1021 | size -= 6; /* header + crc */
|
---|
| 1022 | SKIPBITS(12)
|
---|
| 1023 |
|
---|
| 1024 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1025 |
|
---|
| 1026 | GETBITS(i, 6)
|
---|
| 1027 | eph._prn.set('G', i);
|
---|
| 1028 | GETBITS(week, 10)
|
---|
| 1029 | GETBITS(i, 4)
|
---|
| 1030 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1031 | GETBITS(eph._L2Codes, 2)
|
---|
| 1032 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1033 | GETBITS(eph._IODE, 8)
|
---|
| 1034 | GETBITS(i, 16)
|
---|
| 1035 | i <<= 4;
|
---|
[8158] | 1036 | eph._TOC.set(i * 1000);
|
---|
[8783] | 1037 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1038 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1039 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1040 | GETBITS(eph._IODC, 10)
|
---|
[8783] | 1041 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
| 1042 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1043 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1044 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1045 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1046 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1047 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1048 | if (eph._sqrt_A < 1000.0) {
|
---|
| 1049 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1050 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str())
|
---|
| 1051 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
| 1052 | return false;
|
---|
| 1053 | }
|
---|
[6812] | 1054 | GETBITS(i, 16)
|
---|
| 1055 | i <<= 4;
|
---|
| 1056 | eph._TOEsec = i;
|
---|
| 1057 | bncTime t;
|
---|
[8158] | 1058 | t.set(i * 1000);
|
---|
[6812] | 1059 | eph._TOEweek = t.gpsw();
|
---|
[8472] | 1060 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1061 | week += (numOfRollOvers * 1024);
|
---|
[6812] | 1062 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
[8158] | 1063 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
[6812] | 1064 | return false;
|
---|
[8783] | 1065 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
| 1066 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1067 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
| 1068 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1069 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
| 1070 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1071 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1072 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1073 | GETBITS(eph._health, 6)
|
---|
| 1074 | GETBITS(eph._L2PFlag, 1)
|
---|
[8852] | 1075 | GETBITS(fitIntervalFalg, 1)
|
---|
[8903] | 1076 | eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type());
|
---|
[6812] | 1077 | eph._TOT = 0.9999e9;
|
---|
| 1078 |
|
---|
| 1079 | emit newGPSEph(eph);
|
---|
| 1080 | decoded = true;
|
---|
| 1081 | }
|
---|
| 1082 | return decoded;
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
| 1085 | //
|
---|
| 1086 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1087 | bool RTCM3Decoder::DecodeGLONASSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1088 | bool decoded = false;
|
---|
| 1089 |
|
---|
[8158] | 1090 | if (size == 51) {
|
---|
[6812] | 1091 | t_ephGlo eph;
|
---|
| 1092 | int sv, i, tk;
|
---|
| 1093 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1094 |
|
---|
| 1095 | data += 3; /* header */
|
---|
| 1096 | size -= 6; /* header + crc */
|
---|
| 1097 | SKIPBITS(12)
|
---|
| 1098 |
|
---|
| 1099 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1100 |
|
---|
| 1101 | GETBITS(sv, 6)
|
---|
| 1102 | eph._prn.set('R', sv);
|
---|
| 1103 |
|
---|
| 1104 | GETBITS(i, 5)
|
---|
[8158] | 1105 | eph._frequency_number = i - 7;
|
---|
[8182] | 1106 | GETBITS(eph._almanac_health, 1) /* almanac healthy */
|
---|
| 1107 | GETBITS(eph._almanac_health_availablility_indicator, 1) /* almanac health ok */
|
---|
[9201] | 1108 | if (eph._almanac_health_availablility_indicator == 0.0) {
|
---|
| 1109 | emit(newMessage(QString("%1: Block %2 (%3): ALM = %4: missing data!")
|
---|
| 1110 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str())
|
---|
| 1111 | .arg(eph._almanac_health_availablility_indicator).toLatin1(), true));
|
---|
| 1112 | return false;
|
---|
| 1113 | }
|
---|
[8182] | 1114 | GETBITS(eph._P1, 2) /* P1 */
|
---|
[6812] | 1115 | GETBITS(i, 5)
|
---|
[8158] | 1116 | tk = i * 60 * 60;
|
---|
[6812] | 1117 | GETBITS(i, 6)
|
---|
[8158] | 1118 | tk += i * 60;
|
---|
[6812] | 1119 | GETBITS(i, 1)
|
---|
[8158] | 1120 | tk += i * 30;
|
---|
[8801] | 1121 | eph._tki = tk - 3*60*60;
|
---|
| 1122 | if(eph._tki < 0.0) {
|
---|
| 1123 | eph._tki += 86400.0;
|
---|
| 1124 | }
|
---|
[8182] | 1125 | GETBITS(eph._health, 1) /* MSB of Bn*/
|
---|
| 1126 | GETBITS(eph._P2, 1) /* P2 */
|
---|
[6812] | 1127 | GETBITS(i, 7)
|
---|
[8158] | 1128 | eph._TOC.setTk(i * 15 * 60 * 1000); /* tb */
|
---|
[6812] | 1129 |
|
---|
[8783] | 1130 | GETFLOATSIGNM(eph._x_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1131 | GETFLOATSIGNM(eph._x_pos, 27, 1.0 / (double )(1 << 11))
|
---|
[8158] | 1132 | GETFLOATSIGNM(eph._x_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8783] | 1133 | GETFLOATSIGNM(eph._y_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1134 | GETFLOATSIGNM(eph._y_pos, 27, 1.0 / (double )(1 << 11))
|
---|
[8158] | 1135 | GETFLOATSIGNM(eph._y_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8783] | 1136 | GETFLOATSIGNM(eph._z_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1137 | GETFLOATSIGNM(eph._z_pos, 27, 1.0 / (double )(1 << 11))
|
---|
[8158] | 1138 | GETFLOATSIGNM(eph._z_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8182] | 1139 | GETBITS(eph._P3, 1) /* P3 */
|
---|
[8783] | 1140 | GETFLOATSIGNM(eph._gamma, 11, 1.0 / (double )(1 << 30) / (double )(1 << 10))
|
---|
| 1141 | GETBITS(eph._M_P, 2) /* GLONASS-M P, */
|
---|
[9201] | 1142 | GETBITS(eph._M_l3, 1) /* GLONASS-M ln (third string) */
|
---|
| 1143 | GETFLOATSIGNM(eph._tau, 22, 1.0 / (double )(1 << 30)) /* GLONASS tau n(tb) */
|
---|
[8183] | 1144 | GETFLOATSIGNM(eph._M_delta_tau, 5, 1.0 / (double )(1 << 30)) /* GLONASS-M delta tau n(tb) */
|
---|
[6812] | 1145 | GETBITS(eph._E, 5)
|
---|
[8783] | 1146 | GETBITS(eph._M_P4, 1) /* GLONASS-M P4 */
|
---|
| 1147 | GETBITS(eph._M_FT, 4) /* GLONASS-M Ft */
|
---|
[8182] | 1148 | GETBITS(eph._M_NT, 11) /* GLONASS-M Nt */
|
---|
[9201] | 1149 | if (eph._M_NT == 0.0) {
|
---|
| 1150 | emit(newMessage(QString("%1: Block %2 (%3): NT = %4: missing data!")
|
---|
| 1151 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str()).arg(eph._M_NT,4).toLatin1(), true));
|
---|
| 1152 | return false;
|
---|
| 1153 | }
|
---|
[8783] | 1154 | GETBITS(eph._M_M, 2) /* GLONASS-M M */
|
---|
[8182] | 1155 | GETBITS(eph._additional_data_availability, 1) /* GLONASS-M The Availability of Additional Data */
|
---|
[9201] | 1156 | if (eph._additional_data_availability == 0.0) {
|
---|
| 1157 | emit(newMessage(QString("%1: Block %2 (%3): ADD = %4: missing data!")
|
---|
| 1158 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str())
|
---|
| 1159 | .arg(eph._additional_data_availability).toLatin1(), true));
|
---|
| 1160 | return false;
|
---|
| 1161 | }
|
---|
[8783] | 1162 | GETBITS(eph._NA, 11) /* GLONASS-M Na */
|
---|
| 1163 | GETFLOATSIGNM(eph._tauC, 32, 1.0/(double)(1<<30)/(double)(1<<1)) /* GLONASS tau c */
|
---|
[8182] | 1164 | GETBITS(eph._M_N4, 5) /* GLONASS-M N4 */
|
---|
[8783] | 1165 | GETFLOATSIGNM(eph._M_tau_GPS, 22, 1.0/(double)(1<<30)) /* GLONASS-M tau GPS */
|
---|
[8182] | 1166 | GETBITS(eph._M_l5, 1) /* GLONASS-M ln (fifth string) */
|
---|
[6812] | 1167 |
|
---|
| 1168 | unsigned year, month, day;
|
---|
| 1169 | eph._TOC.civil_date(year, month, day);
|
---|
| 1170 | eph._gps_utc = gnumleap(year, month, day);
|
---|
| 1171 | eph._tt = eph._TOC;
|
---|
[8783] | 1172 |
|
---|
[8708] | 1173 | eph._xv(1) = eph._x_pos * 1.e3;
|
---|
| 1174 | eph._xv(2) = eph._y_pos * 1.e3;
|
---|
| 1175 | eph._xv(3) = eph._z_pos * 1.e3;
|
---|
[9201] | 1176 | if (eph._xv.Rows(1,3).NormFrobenius() < 1.0) {
|
---|
| 1177 | emit(newMessage(QString("%1: Block %2 (%3): zero position!")
|
---|
| 1178 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str()).toLatin1(), true));
|
---|
| 1179 | return false;
|
---|
| 1180 | }
|
---|
[8708] | 1181 | eph._xv(4) = eph._x_velocity * 1.e3;
|
---|
| 1182 | eph._xv(5) = eph._y_velocity * 1.e3;
|
---|
| 1183 | eph._xv(6) = eph._z_velocity * 1.e3;
|
---|
[9201] | 1184 | if (eph._xv.Rows(4,6).NormFrobenius() < 1.0) {
|
---|
| 1185 | emit(newMessage(QString("%1: Block %2 (%3): zero velocity!")
|
---|
| 1186 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str()).toLatin1(), true));
|
---|
| 1187 | return false;
|
---|
| 1188 | }
|
---|
[8186] | 1189 | GLOFreq[sv - 1] = 100 + eph._frequency_number ; /* store frequency for other users (MSM) */
|
---|
| 1190 | _gloFrq = QString("%1 %2").arg(eph._prn.toString().c_str()).arg(eph._frequency_number, 2, 'f', 0);
|
---|
| 1191 |
|
---|
[8708] | 1192 | emit newGlonassEph(eph);
|
---|
| 1193 | decoded = true;
|
---|
[6812] | 1194 | }
|
---|
| 1195 | return decoded;
|
---|
| 1196 | }
|
---|
| 1197 |
|
---|
| 1198 | //
|
---|
| 1199 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1200 | bool RTCM3Decoder::DecodeQZSSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1201 | bool decoded = false;
|
---|
| 1202 |
|
---|
[8158] | 1203 | if (size == 67) {
|
---|
[6812] | 1204 | t_ephGPS eph;
|
---|
| 1205 | int i, week;
|
---|
| 1206 | uint64_t numbits = 0, bitfield = 0;
|
---|
[8852] | 1207 | int fitIntervalFalg = 0;
|
---|
[6812] | 1208 |
|
---|
| 1209 | data += 3; /* header */
|
---|
| 1210 | size -= 6; /* header + crc */
|
---|
| 1211 | SKIPBITS(12)
|
---|
| 1212 |
|
---|
| 1213 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1214 |
|
---|
| 1215 | GETBITS(i, 4)
|
---|
| 1216 | eph._prn.set('J', i);
|
---|
[8476] | 1217 |
|
---|
[6812] | 1218 | GETBITS(i, 16)
|
---|
| 1219 | i <<= 4;
|
---|
[8158] | 1220 | eph._TOC.set(i * 1000);
|
---|
[6812] | 1221 |
|
---|
[8783] | 1222 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1223 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1224 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1225 | GETBITS(eph._IODE, 8)
|
---|
[8783] | 1226 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1227 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1228 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1229 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1230 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1231 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1232 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1233 | if (eph._sqrt_A < 1000.0) {
|
---|
| 1234 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1235 | .arg(_staID).arg(1044,4).arg(eph._prn.toString().c_str())
|
---|
| 1236 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
| 1237 | return false;
|
---|
| 1238 | }
|
---|
[6812] | 1239 | GETBITS(i, 16)
|
---|
| 1240 | i <<= 4;
|
---|
| 1241 | eph._TOEsec = i;
|
---|
| 1242 | bncTime t;
|
---|
[8470] | 1243 | t.set(i*1000);
|
---|
| 1244 | eph._TOEweek = t.gpsw();
|
---|
[8783] | 1245 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
| 1246 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1247 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
| 1248 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1249 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
| 1250 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1251 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1252 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[6812] | 1253 | GETBITS(eph._L2Codes, 2)
|
---|
| 1254 | GETBITS(week, 10)
|
---|
[8472] | 1255 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1256 | week += (numOfRollOvers * 1024);
|
---|
[6812] | 1257 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
[8158] | 1258 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
[6812] | 1259 | return false;
|
---|
| 1260 |
|
---|
| 1261 | GETBITS(i, 4)
|
---|
[8158] | 1262 | if (i <= 6)
|
---|
| 1263 | eph._ura = ceil(10.0 * pow(2.0, 1.0 + i / 2.0)) / 10.0;
|
---|
[6812] | 1264 | else
|
---|
[8158] | 1265 | eph._ura = ceil(10.0 * pow(2.0, i / 2.0)) / 10.0;
|
---|
[6812] | 1266 | GETBITS(eph._health, 6)
|
---|
[8783] | 1267 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1268 | GETBITS(eph._IODC, 10)
|
---|
[8852] | 1269 | GETBITS(fitIntervalFalg, 1)
|
---|
[8903] | 1270 | eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type());
|
---|
[6812] | 1271 | eph._TOT = 0.9999e9;
|
---|
| 1272 |
|
---|
| 1273 | emit newGPSEph(eph);
|
---|
| 1274 | decoded = true;
|
---|
| 1275 | }
|
---|
| 1276 | return decoded;
|
---|
| 1277 | }
|
---|
| 1278 |
|
---|
| 1279 | //
|
---|
| 1280 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8783] | 1281 | bool RTCM3Decoder::DecodeIRNSSEphemeris(unsigned char* data, int size) {
|
---|
| 1282 | bool decoded = false;
|
---|
| 1283 |
|
---|
| 1284 | if (size == 67) {
|
---|
| 1285 | t_ephGPS eph;
|
---|
| 1286 | int i, week, L5Flag, SFlag;
|
---|
| 1287 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1288 |
|
---|
| 1289 | data += 3; /* header */
|
---|
| 1290 | size -= 6; /* header + crc */
|
---|
| 1291 | SKIPBITS(12)
|
---|
| 1292 |
|
---|
| 1293 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1294 |
|
---|
| 1295 | GETBITS(i, 6)
|
---|
| 1296 | eph._prn.set('I', i);
|
---|
| 1297 | GETBITS(week, 10)
|
---|
| 1298 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1299 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1300 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1301 | GETBITS(i, 4)
|
---|
| 1302 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1303 | GETBITS(i, 16)
|
---|
| 1304 | i <<= 4;
|
---|
| 1305 | eph._TOC.set(i * 1000);
|
---|
| 1306 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1307 | GETFLOATSIGN(eph._Delta_n, 22, R2R_PI/(double)(1<<30)/(double)(1 << 11))
|
---|
| 1308 | // IODCE
|
---|
| 1309 | GETBITS(eph._IODE, 8)
|
---|
| 1310 | eph._IODC = eph._IODE;
|
---|
| 1311 | SKIPBITS(10)
|
---|
| 1312 | GETBITS(L5Flag, 1)
|
---|
| 1313 | GETBITS(SFlag, 1)
|
---|
| 1314 | if (L5Flag == 0 && SFlag == 0) {
|
---|
| 1315 | eph._health = 0.0;
|
---|
| 1316 | }
|
---|
| 1317 | else if (L5Flag == 0 && SFlag == 1) {
|
---|
| 1318 | eph._health = 1.0;
|
---|
| 1319 | }
|
---|
| 1320 | else if (L5Flag == 1 && SFlag == 0) {
|
---|
| 1321 | eph._health = 2.0;
|
---|
| 1322 | }
|
---|
| 1323 | else if (L5Flag == 1 && SFlag == 1) {
|
---|
| 1324 | eph._health = 3.0;
|
---|
| 1325 | }
|
---|
| 1326 | GETFLOATSIGN(eph._Cuc, 15, 1.0 / (double )(1 << 28))
|
---|
| 1327 | GETFLOATSIGN(eph._Cus, 15, 1.0 / (double )(1 << 28))
|
---|
| 1328 | GETFLOATSIGN(eph._Cic, 15, 1.0 / (double )(1 << 28))
|
---|
| 1329 | GETFLOATSIGN(eph._Cis, 15, 1.0 / (double )(1 << 28))
|
---|
| 1330 | GETFLOATSIGN(eph._Crc, 15, 1.0 / (double )(1 << 4))
|
---|
| 1331 | GETFLOATSIGN(eph._Crs, 15, 1.0 / (double )(1 << 4))
|
---|
| 1332 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1333 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1334 | GETBITS(i, 16)
|
---|
| 1335 | i <<= 4;
|
---|
| 1336 | eph._TOEsec = i;
|
---|
| 1337 | bncTime t;
|
---|
| 1338 | t.set(i * 1000);
|
---|
| 1339 | eph._TOEweek = t.gpsw();
|
---|
| 1340 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1341 | week += (numOfRollOvers * 1024);
|
---|
| 1342 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
| 1343 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
| 1344 | return false;
|
---|
| 1345 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1346 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1347 | if (eph._sqrt_A < 1000.0) {
|
---|
| 1348 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1349 | .arg(_staID).arg(1041,4).arg(eph._prn.toString().c_str())
|
---|
| 1350 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
| 1351 | return false;
|
---|
| 1352 | }
|
---|
[8783] | 1353 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1354 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1355 | GETFLOATSIGN(eph._OMEGADOT, 22, R2R_PI/(double)(1<<30)/(double)(1<<11))
|
---|
| 1356 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1357 | SKIPBITS(2)
|
---|
| 1358 | SKIPBITS(2)
|
---|
| 1359 | eph._TOT = 0.9999e9;
|
---|
| 1360 |
|
---|
| 1361 | emit newGPSEph(eph);
|
---|
| 1362 | decoded = true;
|
---|
| 1363 | }
|
---|
| 1364 | return decoded;
|
---|
| 1365 | }
|
---|
| 1366 |
|
---|
| 1367 | //
|
---|
| 1368 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1369 | bool RTCM3Decoder::DecodeSBASEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1370 | bool decoded = false;
|
---|
| 1371 |
|
---|
[8158] | 1372 | if (size == 35) {
|
---|
[6812] | 1373 | t_ephSBAS eph;
|
---|
| 1374 | int i;
|
---|
| 1375 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1376 |
|
---|
| 1377 | data += 3; /* header */
|
---|
| 1378 | size -= 6; /* header + crc */
|
---|
| 1379 | SKIPBITS(12)
|
---|
| 1380 |
|
---|
| 1381 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1382 |
|
---|
| 1383 | GETBITS(i, 6)
|
---|
[8158] | 1384 | eph._prn.set('S', 20 + i);
|
---|
[6812] | 1385 | GETBITS(eph._IODN, 8)
|
---|
| 1386 | GETBITS(i, 13)
|
---|
| 1387 | i <<= 4;
|
---|
[8158] | 1388 | eph._TOC.setTOD(i * 1000);
|
---|
[6812] | 1389 | GETBITS(i, 4)
|
---|
| 1390 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1391 | GETFLOATSIGN(eph._x_pos, 30, 0.08)
|
---|
| 1392 | GETFLOATSIGN(eph._y_pos, 30, 0.08)
|
---|
| 1393 | GETFLOATSIGN(eph._z_pos, 25, 0.4)
|
---|
[9201] | 1394 | ColumnVector pos(3);
|
---|
| 1395 | pos(1) = eph._x_pos; pos(2) = eph._y_pos; pos(3) = eph._z_pos;
|
---|
| 1396 | if (pos.NormFrobenius() < 1.0) {
|
---|
| 1397 | emit(newMessage(QString("%1: Block %2 (%3): zero position!")
|
---|
| 1398 | .arg(_staID).arg(1043,4).arg(eph._prn.toString().c_str()).toLatin1(), true));
|
---|
| 1399 | return false;
|
---|
| 1400 | }
|
---|
[6812] | 1401 | GETFLOATSIGN(eph._x_velocity, 17, 0.000625)
|
---|
| 1402 | GETFLOATSIGN(eph._y_velocity, 17, 0.000625)
|
---|
| 1403 | GETFLOATSIGN(eph._z_velocity, 18, 0.004)
|
---|
| 1404 | GETFLOATSIGN(eph._x_acceleration, 10, 0.0000125)
|
---|
| 1405 | GETFLOATSIGN(eph._y_acceleration, 10, 0.0000125)
|
---|
| 1406 | GETFLOATSIGN(eph._z_acceleration, 10, 0.0000625)
|
---|
[8158] | 1407 | GETFLOATSIGN(eph._agf0, 12, 1.0 / (1 << 30) / (1 << 1))
|
---|
| 1408 | GETFLOATSIGN(eph._agf1, 8, 1.0 / (1 << 30) / (1 << 10))
|
---|
[6812] | 1409 |
|
---|
[8456] | 1410 | eph._TOT = 0.9999E9;
|
---|
[6812] | 1411 | eph._health = 0;
|
---|
| 1412 |
|
---|
| 1413 | emit newSBASEph(eph);
|
---|
| 1414 | decoded = true;
|
---|
| 1415 | }
|
---|
| 1416 | return decoded;
|
---|
| 1417 | }
|
---|
| 1418 |
|
---|
| 1419 | //
|
---|
| 1420 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1421 | bool RTCM3Decoder::DecodeGalileoEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1422 | bool decoded = false;
|
---|
| 1423 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1424 | int i;
|
---|
| 1425 |
|
---|
| 1426 | data += 3; /* header */
|
---|
| 1427 | size -= 6; /* header + crc */
|
---|
| 1428 | GETBITS(i, 12)
|
---|
| 1429 |
|
---|
[8158] | 1430 | if ((i == 1046 && size == 61) || (i == 1045 && size == 60)) {
|
---|
[6812] | 1431 | t_ephGal eph;
|
---|
| 1432 |
|
---|
| 1433 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1434 |
|
---|
| 1435 | eph._inav = (i == 1046);
|
---|
| 1436 | eph._fnav = (i == 1045);
|
---|
| 1437 | GETBITS(i, 6)
|
---|
| 1438 | eph._prn.set('E', i, eph._inav ? 1 : 0);
|
---|
| 1439 |
|
---|
[8783] | 1440 | GETBITS(eph._TOEweek, 12) //FIXME: roll-over after week 4095!!
|
---|
[6812] | 1441 | GETBITS(eph._IODnav, 10)
|
---|
| 1442 | GETBITS(i, 8)
|
---|
| 1443 | eph._SISA = accuracyFromIndex(i, eph.type());
|
---|
| 1444 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1445 | GETBITSFACTOR(i, 14, 60)
|
---|
[8158] | 1446 | eph._TOC.set(1024 + eph._TOEweek, i);
|
---|
[8783] | 1447 | GETFLOATSIGN(eph._clock_driftrate, 6, 1.0 / (double )(1 << 30) / (double )(1 << 29))
|
---|
| 1448 | GETFLOATSIGN(eph._clock_drift, 21, 1.0 / (double )(1 << 30) / (double )(1 << 16))
|
---|
| 1449 | GETFLOATSIGN(eph._clock_bias, 31, 1.0 / (double )(1 << 30) / (double )(1 << 4))
|
---|
| 1450 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
| 1451 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1452 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1453 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1454 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1455 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1456 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[6812] | 1457 | GETBITSFACTOR(eph._TOEsec, 14, 60)
|
---|
| 1458 | /* FIXME: overwrite value, copied from old code */
|
---|
| 1459 | eph._TOEsec = eph._TOC.gpssec();
|
---|
[8783] | 1460 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
| 1461 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1462 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
| 1463 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1464 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
| 1465 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1466 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8981] | 1467 | GETFLOATSIGN(eph._BGD_1_5A, 10, 1.0 / (double )(1 << 30) / (double )(1 << 2))
|
---|
[8158] | 1468 | if (eph._inav) {
|
---|
[7006] | 1469 | /* set unused F/NAV values */
|
---|
[6812] | 1470 | eph._E5aHS = 0.0;
|
---|
| 1471 | eph._e5aDataInValid = false;
|
---|
| 1472 |
|
---|
[8783] | 1473 | GETFLOATSIGN(eph._BGD_1_5B, 10, 1.0 / (double )(1 << 30) / (double )(1 << 2))
|
---|
[6812] | 1474 | GETBITS(eph._E5bHS, 2)
|
---|
| 1475 | GETBITS(eph._e5bDataInValid, 1)
|
---|
| 1476 | GETBITS(eph._E1_bHS, 2)
|
---|
| 1477 | GETBITS(eph._e1DataInValid, 1)
|
---|
[9192] | 1478 | if (eph._E5bHS != eph._E1_bHS) {
|
---|
[9201] | 1479 | emit(newMessage(QString("%1: Block %2 (%3) SHS E5b %4 E1B %5: inconsistent health!")
|
---|
| 1480 | .arg(_staID).arg(1046,4).arg(eph._prn.toString().c_str())
|
---|
| 1481 | .arg(eph._E5bHS).arg(eph._E1_bHS).toLatin1(), true));
|
---|
[9192] | 1482 | return false;
|
---|
| 1483 | }
|
---|
| 1484 | if ((eph._BGD_1_5A == 0.0 && fabs(eph._BGD_1_5B) > 1e-9) ||
|
---|
| 1485 | (eph._BGD_1_5B == 0.0 && fabs(eph._BGD_1_5A) > 1e-9)) {
|
---|
[9201] | 1486 | emit(newMessage(QString("%1: Block %2 (%3) BGD_15a = %4 BGD_15b = %5: inconsistent BGD!")
|
---|
| 1487 | .arg(_staID).arg(1046,4).arg(eph._prn.toString().c_str())
|
---|
| 1488 | .arg(eph._BGD_1_5A,10,'E',3).arg(eph._BGD_1_5B,10,'E',3).toLatin1(), true));
|
---|
[9192] | 1489 | return false;
|
---|
| 1490 | }
|
---|
[6812] | 1491 | }
|
---|
[8158] | 1492 | else {
|
---|
[7006] | 1493 | /* set unused I/NAV values */
|
---|
[6812] | 1494 | eph._BGD_1_5B = 0.0;
|
---|
| 1495 | eph._E5bHS = 0.0;
|
---|
| 1496 | eph._E1_bHS = 0.0;
|
---|
| 1497 | eph._e1DataInValid = false;
|
---|
| 1498 | eph._e5bDataInValid = false;
|
---|
| 1499 |
|
---|
| 1500 | GETBITS(eph._E5aHS, 2)
|
---|
| 1501 | GETBITS(eph._e5aDataInValid, 1)
|
---|
| 1502 | }
|
---|
| 1503 | eph._TOT = 0.9999e9;
|
---|
| 1504 |
|
---|
[9201] | 1505 | if (eph._sqrt_A < 1000.0) {
|
---|
| 1506 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1507 | .arg(_staID).arg(eph._inav? 1046 : 1045,4).arg(eph._prn.toString().c_str())
|
---|
| 1508 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
| 1509 | return false;
|
---|
| 1510 | }
|
---|
| 1511 |
|
---|
[6812] | 1512 | emit newGalileoEph(eph);
|
---|
| 1513 | decoded = true;
|
---|
| 1514 | }
|
---|
| 1515 | return decoded;
|
---|
| 1516 | }
|
---|
| 1517 |
|
---|
| 1518 | //
|
---|
| 1519 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1520 | bool RTCM3Decoder::DecodeBDSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1521 | bool decoded = false;
|
---|
| 1522 |
|
---|
[8158] | 1523 | if (size == 70) {
|
---|
[6812] | 1524 | t_ephBDS eph;
|
---|
| 1525 | int i;
|
---|
| 1526 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1527 |
|
---|
| 1528 | data += 3; /* header */
|
---|
| 1529 | size -= 6; /* header + crc */
|
---|
| 1530 | SKIPBITS(12)
|
---|
| 1531 |
|
---|
| 1532 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
| 1533 |
|
---|
| 1534 | GETBITS(i, 6)
|
---|
| 1535 | eph._prn.set('C', i);
|
---|
| 1536 |
|
---|
[8158] | 1537 | SKIPBITS(13)
|
---|
| 1538 | /* week */
|
---|
[6812] | 1539 | GETBITS(i, 4)
|
---|
| 1540 | eph._URA = accuracyFromIndex(i, eph.type());
|
---|
| 1541 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1542 | GETBITS(eph._AODE, 5)
|
---|
| 1543 | GETBITS(i, 17)
|
---|
| 1544 | i <<= 3;
|
---|
[8158] | 1545 | eph._TOC.setBDS(i * 1000);
|
---|
[8783] | 1546 | GETFLOATSIGN(eph._clock_driftrate, 11, 1.0 / (double )(1 << 30) / (double )(1 << 30) / (double )(1 << 6))
|
---|
| 1547 | GETFLOATSIGN(eph._clock_drift, 22, 1.0 / (double )(1 << 30) / (double )(1 << 20))
|
---|
| 1548 | GETFLOATSIGN(eph._clock_bias, 24, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
[6812] | 1549 | GETBITS(eph._AODC, 5)
|
---|
[8783] | 1550 | GETFLOATSIGN(eph._Crs, 18, 1.0 / (double )(1 << 6))
|
---|
[6812] | 1551 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1552 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1553 | GETFLOATSIGN(eph._Cuc, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1554 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1555 | GETFLOATSIGN(eph._Cus, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1556 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1557 | if (eph._sqrt_A < 1000.0) {
|
---|
| 1558 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1559 | .arg(_staID).arg(1042,4).arg(eph._prn.toString().c_str())
|
---|
| 1560 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
| 1561 | return false;
|
---|
| 1562 | }
|
---|
[6812] | 1563 | GETBITS(i, 17)
|
---|
| 1564 | i <<= 3;
|
---|
| 1565 | eph._TOEsec = i;
|
---|
[8158] | 1566 | eph._TOE.setBDS(i * 1000);
|
---|
[8783] | 1567 | GETFLOATSIGN(eph._Cic, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1568 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1569 | GETFLOATSIGN(eph._Cis, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1570 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1571 | GETFLOATSIGN(eph._Crc, 18, 1.0 / (double )(1 << 6))
|
---|
| 1572 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1573 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1574 | GETFLOATSIGN(eph._TGD1, 10, 0.0000000001)
|
---|
| 1575 | GETFLOATSIGN(eph._TGD2, 10, 0.0000000001)
|
---|
[6812] | 1576 | GETBITS(eph._SatH1, 1)
|
---|
| 1577 |
|
---|
[8456] | 1578 | eph._TOT = 0.9999E9;
|
---|
[6812] | 1579 | emit newBDSEph(eph);
|
---|
| 1580 | decoded = true;
|
---|
| 1581 | }
|
---|
| 1582 | return decoded;
|
---|
| 1583 | }
|
---|
| 1584 |
|
---|
[8197] | 1585 | //
|
---|
| 1586 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1587 | bool RTCM3Decoder::DecodeAntennaReceiver(unsigned char* data, int size) {
|
---|
[8234] | 1588 | char *antenna;
|
---|
| 1589 | char *antserialnum;
|
---|
| 1590 | char *receiver;
|
---|
| 1591 | char *recfirmware;
|
---|
| 1592 | char *recserialnum;
|
---|
[8197] | 1593 | int type;
|
---|
[8234] | 1594 | int antsernum = -1;
|
---|
[8197] | 1595 | int antnum = -1;
|
---|
| 1596 | int recnum = -1;
|
---|
[8234] | 1597 | int recsernum = -1;
|
---|
| 1598 | int recfirnum = -1;
|
---|
[8197] | 1599 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1600 |
|
---|
| 1601 | data += 3; /* header*/
|
---|
| 1602 | size -= 6; /* header + crc */
|
---|
| 1603 |
|
---|
[8198] | 1604 | GETBITS(type, 12)
|
---|
[8234] | 1605 | SKIPBITS(12) /* reference station ID */
|
---|
[8197] | 1606 | GETSTRING(antnum, antenna)
|
---|
[8234] | 1607 | if ((antnum > -1 && antnum < 265) &&
|
---|
| 1608 | (_antType.empty() || strncmp(_antType.back().descriptor, antenna, recnum) != 0)) {
|
---|
| 1609 | _antType.push_back(t_antInfo());
|
---|
| 1610 | memcpy(_antType.back().descriptor, antenna, antnum);
|
---|
| 1611 | _antType.back().descriptor[antnum] = 0;
|
---|
| 1612 | }
|
---|
| 1613 | SKIPBITS(8) /* antenna setup ID */
|
---|
| 1614 | if (type == 1008 || type == 1033 ) {
|
---|
| 1615 | GETSTRING(antsernum, antserialnum)
|
---|
| 1616 | if ((antsernum > -1 && antsernum < 265)) {
|
---|
| 1617 | memcpy(_antType.back().serialnumber, antserialnum, antsernum);
|
---|
| 1618 | _antType.back().serialnumber[antsernum] = 0;
|
---|
[8197] | 1619 | }
|
---|
| 1620 | }
|
---|
[8234] | 1621 |
|
---|
[8197] | 1622 | if (type == 1033) {
|
---|
| 1623 | GETSTRING(recnum, receiver)
|
---|
[8234] | 1624 | GETSTRING(recfirnum, recfirmware)
|
---|
| 1625 | GETSTRING(recsernum, recserialnum)
|
---|
| 1626 | if ((recnum > -1 && recnum < 265) &&
|
---|
| 1627 | (_recType.empty() || strncmp(_recType.back().descriptor, receiver, recnum) != 0)) {
|
---|
| 1628 | _recType.push_back(t_recInfo());
|
---|
| 1629 | memcpy(_recType.back().descriptor, receiver, recnum);
|
---|
| 1630 | _recType.back().descriptor[recnum] = 0;
|
---|
| 1631 | if (recfirnum > -1 && recfirnum < 265) {
|
---|
| 1632 | memcpy(_recType.back().firmware, recfirmware, recfirnum);
|
---|
| 1633 | _recType.back().firmware[recfirnum] = 0;
|
---|
[8197] | 1634 | }
|
---|
[8234] | 1635 | if (recsernum > -1 && recsernum < 265) {
|
---|
| 1636 | memcpy(_recType.back().serialnumber, recserialnum, recsernum);
|
---|
| 1637 | _recType.back().serialnumber[recsernum] = 0;
|
---|
| 1638 | }
|
---|
[8197] | 1639 | }
|
---|
| 1640 | }
|
---|
| 1641 | return true;
|
---|
[6812] | 1642 | }
|
---|
| 1643 |
|
---|
| 1644 | //
|
---|
| 1645 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1646 | bool RTCM3Decoder::DecodeAntennaPosition(unsigned char* data, int size) {
|
---|
[6812] | 1647 | int type;
|
---|
| 1648 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1649 | double x, y, z;
|
---|
| 1650 |
|
---|
| 1651 | data += 3; /* header */
|
---|
| 1652 | size -= 6; /* header + crc */
|
---|
| 1653 |
|
---|
| 1654 | GETBITS(type, 12)
|
---|
[8234] | 1655 | _antList.push_back(t_antRefPoint());
|
---|
| 1656 | _antList.back().type = t_antRefPoint::ARP;
|
---|
[6812] | 1657 | SKIPBITS(22)
|
---|
| 1658 | GETBITSSIGN(x, 38)
|
---|
| 1659 | _antList.back().xx = x * 1e-4;
|
---|
| 1660 | SKIPBITS(2)
|
---|
| 1661 | GETBITSSIGN(y, 38)
|
---|
| 1662 | _antList.back().yy = y * 1e-4;
|
---|
| 1663 | SKIPBITS(2)
|
---|
| 1664 | GETBITSSIGN(z, 38)
|
---|
| 1665 | _antList.back().zz = z * 1e-4;
|
---|
[8158] | 1666 | if (type == 1006)
|
---|
| 1667 | {
|
---|
[6812] | 1668 | double h;
|
---|
| 1669 | GETBITS(h, 16)
|
---|
| 1670 | _antList.back().height = h * 1e-4;
|
---|
| 1671 | _antList.back().height_f = true;
|
---|
| 1672 | }
|
---|
[8158] | 1673 | _antList.back().message = type;
|
---|
[6812] | 1674 |
|
---|
| 1675 | return true;
|
---|
| 1676 | }
|
---|
| 1677 |
|
---|
[7753] | 1678 | //
|
---|
[6812] | 1679 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1680 | t_irc RTCM3Decoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
---|
[6812] | 1681 | bool decoded = false;
|
---|
| 1682 |
|
---|
| 1683 | errmsg.clear();
|
---|
| 1684 |
|
---|
[8158] | 1685 | while (bufLen && _MessageSize < sizeof(_Message)) {
|
---|
[6812] | 1686 | int l = sizeof(_Message) - _MessageSize;
|
---|
[8158] | 1687 | if (l > bufLen)
|
---|
[6812] | 1688 | l = bufLen;
|
---|
[8158] | 1689 | memcpy(_Message + _MessageSize, buffer, l);
|
---|
[6812] | 1690 | _MessageSize += l;
|
---|
| 1691 | bufLen -= l;
|
---|
| 1692 | buffer += l;
|
---|
| 1693 | int id;
|
---|
[8158] | 1694 | while ((id = GetMessage())) {
|
---|
[6812] | 1695 | /* reset station ID for file loading as it can change */
|
---|
[8158] | 1696 | if (_rawFile)
|
---|
[6812] | 1697 | _staID = _rawFile->staID();
|
---|
| 1698 | /* store the id into the list of loaded blocks */
|
---|
| 1699 | _typeList.push_back(id);
|
---|
| 1700 |
|
---|
[6856] | 1701 | /* SSR I+II data handled in another function, already pass the
|
---|
[6812] | 1702 | * extracted data block. That does no harm, as it anyway skip everything
|
---|
| 1703 | * else. */
|
---|
[8971] | 1704 | if ((id >= 1057 && id <= 1068) ||
|
---|
[9124] | 1705 | (id >= 1240 && id <= 1270) ||
|
---|
| 1706 | (id == 4076)) {
|
---|
[9048] | 1707 | if (!_coDecoders.contains(_staID.toLatin1())) {
|
---|
| 1708 | _coDecoders[_staID.toLatin1()] = new RTCM3coDecoder(_staID);
|
---|
| 1709 | }
|
---|
| 1710 | RTCM3coDecoder* coDecoder = _coDecoders[_staID.toLatin1()];
|
---|
[9025] | 1711 | if (id == 4076) {
|
---|
[9048] | 1712 | coDecoder->setSsrFormatType(RTCM3coDecoder::IGSssr);
|
---|
[9025] | 1713 | }
|
---|
[9048] | 1714 | else {
|
---|
| 1715 | coDecoder->setSsrFormatType(RTCM3coDecoder::RTCMssr);
|
---|
| 1716 | }
|
---|
[8158] | 1717 | if (coDecoder->Decode(reinterpret_cast<char *>(_Message), _BlockSize,
|
---|
| 1718 | errmsg) == success) {
|
---|
[6812] | 1719 | decoded = true;
|
---|
| 1720 | }
|
---|
| 1721 | }
|
---|
[9000] | 1722 | else if (id >= 1070 && id <= 1229) { /* MSM */
|
---|
[8158] | 1723 | if (DecodeRTCM3MSM(_Message, _BlockSize))
|
---|
[6812] | 1724 | decoded = true;
|
---|
| 1725 | }
|
---|
[8158] | 1726 | else {
|
---|
| 1727 | switch (id) {
|
---|
| 1728 | case 1001:
|
---|
| 1729 | case 1003:
|
---|
| 1730 | emit(newMessage(
|
---|
| 1731 | QString("%1: Block %2 contain partial data! Ignored!")
|
---|
[8204] | 1732 | .arg(_staID).arg(id).toLatin1(), true));
|
---|
[8158] | 1733 | break; /* no use decoding partial data ATM, remove break when data can be used */
|
---|
| 1734 | case 1002:
|
---|
| 1735 | case 1004:
|
---|
| 1736 | if (DecodeRTCM3GPS(_Message, _BlockSize))
|
---|
| 1737 | decoded = true;
|
---|
| 1738 | break;
|
---|
| 1739 | case 1009:
|
---|
| 1740 | case 1011:
|
---|
| 1741 | emit(newMessage(
|
---|
| 1742 | QString("%1: Block %2 contain partial data! Ignored!")
|
---|
[8204] | 1743 | .arg(_staID).arg(id).toLatin1(), true));
|
---|
[8158] | 1744 | break; /* no use decoding partial data ATM, remove break when data can be used */
|
---|
| 1745 | case 1010:
|
---|
| 1746 | case 1012:
|
---|
| 1747 | if (DecodeRTCM3GLONASS(_Message, _BlockSize))
|
---|
| 1748 | decoded = true;
|
---|
| 1749 | break;
|
---|
| 1750 | case 1019:
|
---|
| 1751 | if (DecodeGPSEphemeris(_Message, _BlockSize))
|
---|
| 1752 | decoded = true;
|
---|
| 1753 | break;
|
---|
| 1754 | case 1020:
|
---|
| 1755 | if (DecodeGLONASSEphemeris(_Message, _BlockSize))
|
---|
| 1756 | decoded = true;
|
---|
| 1757 | break;
|
---|
| 1758 | case 1043:
|
---|
| 1759 | if (DecodeSBASEphemeris(_Message, _BlockSize))
|
---|
| 1760 | decoded = true;
|
---|
| 1761 | break;
|
---|
| 1762 | case 1044:
|
---|
| 1763 | if (DecodeQZSSEphemeris(_Message, _BlockSize))
|
---|
| 1764 | decoded = true;
|
---|
| 1765 | break;
|
---|
[9002] | 1766 | case 1041:
|
---|
[8783] | 1767 | if (DecodeIRNSSEphemeris(_Message, _BlockSize))
|
---|
| 1768 | decoded = true;
|
---|
| 1769 | break;
|
---|
[8158] | 1770 | case 1045:
|
---|
| 1771 | case 1046:
|
---|
[9192] | 1772 | if (_staID.contains("AIRA") || _staID.contains("STK2") ||
|
---|
| 1773 | _staID.contains("CCJ2") || _staID.contains("SYOG")) {
|
---|
[9204] | 1774 | emit(newMessage(QString("%1: Block temporary %2 from JAXA RTKLIB encoded stations!")
|
---|
| 1775 | .arg(_staID).arg(id).toLatin1(), true));
|
---|
[9192] | 1776 | break;
|
---|
| 1777 | }
|
---|
[8158] | 1778 | if (DecodeGalileoEphemeris(_Message, _BlockSize))
|
---|
| 1779 | decoded = true;
|
---|
| 1780 | break;
|
---|
[9000] | 1781 | case 1042:
|
---|
[8158] | 1782 | if (DecodeBDSEphemeris(_Message, _BlockSize))
|
---|
| 1783 | decoded = true;
|
---|
| 1784 | break;
|
---|
| 1785 | case 1007:
|
---|
| 1786 | case 1008:
|
---|
| 1787 | case 1033:
|
---|
[8197] | 1788 | DecodeAntennaReceiver(_Message, _BlockSize);
|
---|
[8158] | 1789 | break;
|
---|
| 1790 | case 1005:
|
---|
| 1791 | case 1006:
|
---|
| 1792 | DecodeAntennaPosition(_Message, _BlockSize);
|
---|
| 1793 | break;
|
---|
[296] | 1794 | }
|
---|
| 1795 | }
|
---|
| 1796 | }
|
---|
[6812] | 1797 | }
|
---|
| 1798 | return decoded ? success : failure;
|
---|
[8158] | 1799 | }
|
---|
| 1800 | ;
|
---|
[6812] | 1801 |
|
---|
[7753] | 1802 | //
|
---|
[6812] | 1803 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1804 | uint32_t RTCM3Decoder::CRC24(long size, const unsigned char *buf) {
|
---|
[6812] | 1805 | uint32_t crc = 0;
|
---|
[9025] | 1806 | int ii;
|
---|
[8158] | 1807 | while (size--) {
|
---|
[6812] | 1808 | crc ^= (*buf++) << (16);
|
---|
[9025] | 1809 | for (ii = 0; ii < 8; ii++) {
|
---|
[6812] | 1810 | crc <<= 1;
|
---|
[8158] | 1811 | if (crc & 0x1000000)
|
---|
[6812] | 1812 | crc ^= 0x01864cfb;
|
---|
[1021] | 1813 | }
|
---|
[296] | 1814 | }
|
---|
[6812] | 1815 | return crc;
|
---|
| 1816 | }
|
---|
[1021] | 1817 |
|
---|
[7753] | 1818 | //
|
---|
[6812] | 1819 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1820 | int RTCM3Decoder::GetMessage(void) {
|
---|
[6812] | 1821 | unsigned char *m, *e;
|
---|
| 1822 | int i;
|
---|
| 1823 |
|
---|
[8158] | 1824 | m = _Message + _SkipBytes;
|
---|
| 1825 | e = _Message + _MessageSize;
|
---|
[6812] | 1826 | _NeedBytes = _SkipBytes = 0;
|
---|
[8158] | 1827 | while (e - m >= 3) {
|
---|
| 1828 | if (m[0] == 0xD3) {
|
---|
| 1829 | _BlockSize = ((m[1] & 3) << 8) | m[2];
|
---|
| 1830 | if (e - m >= static_cast<int>(_BlockSize + 6)) {
|
---|
| 1831 | if (static_cast<uint32_t>((m[3 + _BlockSize] << 16)
|
---|
| 1832 | | (m[3 + _BlockSize + 1] << 8)
|
---|
| 1833 | | (m[3 + _BlockSize + 2])) == CRC24(_BlockSize + 3, m)) {
|
---|
| 1834 | _BlockSize += 6;
|
---|
[6812] | 1835 | _SkipBytes = _BlockSize;
|
---|
| 1836 | break;
|
---|
| 1837 | }
|
---|
| 1838 | else
|
---|
| 1839 | ++m;
|
---|
| 1840 | }
|
---|
[8158] | 1841 | else {
|
---|
[6812] | 1842 | _NeedBytes = _BlockSize;
|
---|
| 1843 | break;
|
---|
| 1844 | }
|
---|
| 1845 | }
|
---|
| 1846 | else
|
---|
| 1847 | ++m;
|
---|
[658] | 1848 | }
|
---|
[8158] | 1849 | if (e - m < 3)
|
---|
[6812] | 1850 | _NeedBytes = 3;
|
---|
| 1851 |
|
---|
| 1852 | /* copy buffer to front */
|
---|
| 1853 | i = m - _Message;
|
---|
[8158] | 1854 | if (i && m < e)
|
---|
| 1855 | memmove(_Message, m, static_cast<size_t>(_MessageSize - i));
|
---|
[6812] | 1856 | _MessageSize -= i;
|
---|
| 1857 |
|
---|
[8158] | 1858 | return !_NeedBytes ? ((_Message[3] << 4) | (_Message[4] >> 4)) : 0;
|
---|
[296] | 1859 | }
|
---|
[1807] | 1860 |
|
---|
[3001] | 1861 | // Time of Corrections
|
---|
| 1862 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1863 | int RTCM3Decoder::corrGPSEpochTime() const {
|
---|
[8158] | 1864 | return
|
---|
| 1865 | _coDecoders.size() > 0 ?
|
---|
| 1866 | _coDecoders.begin().value()->corrGPSEpochTime() : -1;
|
---|
[3001] | 1867 | }
|
---|