Changeset 7053 in ntrip for trunk/BNC/src/RTCM3/ephEncoder.cpp


Ignore:
Timestamp:
Jul 16, 2015, 9:43:15 AM (9 years ago)
Author:
stuerze
Message:

CRC24 calculation as well as some definitions required for ephemeris encoding were shifted to have them also somewhere else available

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM3/ephEncoder.cpp

    r6869 r7053  
    44using namespace std;
    55
    6 // Returns CRC24
    7 ////////////////////////////////////////////////////////////////////////////
    8 static unsigned long CRC24(long size, const unsigned char *buf) {
    9   unsigned long crc = 0;
    10   int ii;
    11   while (size--) {
    12     crc ^= (*buf++) << (16);
    13     for(ii = 0; ii < 8; ii++) {
    14       crc <<= 1;
    15       if (crc & 0x1000000) {
    16         crc ^= 0x01864cfb;
    17       }
    18     }
    19   }
    20   return crc;
    21 }
    226
    237// build up RTCM3 for GPS
    248////////////////////////////////////////////////////////////////////////////
    25 #define GPSTOINT(type, value) static_cast<type>(round(value))
    26 
    27 #define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
    28                        |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \
    29                        numbits += (a); \
    30                        while(numbits >= 8) { \
    31                        buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
    32 
    33 #define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \
    34                              GPSADDBITS(a,i)};
    35 
    369int t_ephEncoder::RTCM3(const t_ephGPS& eph, unsigned char *buffer) {
    3710
     
    138111// build up RTCM3 for GLONASS
    139112////////////////////////////////////////////////////////////////////////////
    140 #define GLONASSTOINT(type, value) static_cast<type>(round(value))
    141 
    142 #define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
    143                        |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \
    144                        numbits += (a); \
    145                        while(numbits >= 8) { \
    146                        buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
    147 #define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \
    148                        if(b < 0.0) \
    149                        { \
    150                          s = 1; \
    151                          i = GLONASSTOINT(long long,(-b)/(c)); \
    152                          if(!i) s = 0; \
    153                        } \
    154                        else \
    155                        { \
    156                          s = 0; \
    157                          i = GLONASSTOINT(long long,(b)/(c)); \
    158                        } \
    159                        GLONASSADDBITS(1,s) \
    160                        GLONASSADDBITS(a-1,i)}
    161 
    162113int t_ephEncoder::RTCM3(const t_ephGlo& eph, unsigned char *buffer)
    163114{
     
    225176// build up RTCM3 for Galileo
    226177////////////////////////////////////////////////////////////////////////////
    227 #define GALILEOTOINT(type, value) static_cast<type>(round(value))
    228 
    229 #define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
    230                        |(GALILEOTOINT(long long,b)&((1LL<<a)-1)); \
    231                        numbits += (a); \
    232                        while(numbits >= 8) { \
    233                        buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
    234 #define GALILEOADDBITSFLOAT(a,b,c) {long long i = GALILEOTOINT(long long,(b)/(c)); \
    235                              GALILEOADDBITS(a,i)};
    236 
    237178int t_ephEncoder::RTCM3(const t_ephGal& eph, unsigned char *buffer) {
    238179  int size = 0;
     
    309250// build up RTCM3 for SBAS
    310251////////////////////////////////////////////////////////////////////////////
    311 #define SBASTOINT(type, value) static_cast<type>(round(value))
    312 
    313 #define SBASADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
    314                        |(SBASTOINT(long long,b)&((1ULL<<a)-1)); \
    315                        numbits += (a); \
    316                        while(numbits >= 8) { \
    317                        buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
    318 #define SBASADDBITSFLOAT(a,b,c) {long long i = SBASTOINT(long long,(b)/(c)); \
    319                              SBASADDBITS(a,i)};
    320 
    321252int t_ephEncoder::RTCM3(const t_ephSBAS& eph, unsigned char* buffer) {
    322253  int size = 0;
     
    358289// build up RTCM3 for BDS
    359290////////////////////////////////////////////////////////////////////////////
    360 #define BDSTOINT(type, value) static_cast<type>(round(value))
    361 
    362 #define BDSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
    363                        |(BDSTOINT(long long,b)&((1ULL<<a)-1)); \
    364                        numbits += (a); \
    365                        while(numbits >= 8) { \
    366                        buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
    367 #define BDSADDBITSFLOAT(a,b,c) {long long i = BDSTOINT(long long,(b)/(c)); \
    368                              BDSADDBITS(a,i)};
    369 
    370291int t_ephEncoder::RTCM3(const t_ephBDS& eph, unsigned char* buffer) {
    371292  int size = 0;
     
    418339  return size;
    419340}
     341
Note: See TracChangeset for help on using the changeset viewer.