Changeset 7053 in ntrip for trunk/BNC/src/bncutils.h


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/bncutils.h

    r6812 r7053  
    134134int          indexFromAccuracy(double accuracy, t_eph::e_type type);
    135135
     136
     137// CRC24Q checksum calculation function (only full bytes supported).
     138///////////////////////////////////////////////////////////////////
     139unsigned long CRC24(long size, const unsigned char *buf);
     140
     141// RTCM3 GPS EPH encoding
     142//////////////////////////////////////////////////////////
     143#define GPSTOINT(type, value) static_cast<type>(round(value))
     144
     145#define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
     146                       |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \
     147                       numbits += (a); \
     148                       while(numbits >= 8) { \
     149                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
     150
     151#define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \
     152                             GPSADDBITS(a,i)};
     153
     154// RTCM3 GLONASS EPH encoding
     155//////////////////////////////////////////////////////////
     156#define GLONASSTOINT(type, value) static_cast<type>(round(value))
     157#define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
     158                       |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \
     159                       numbits += (a); \
     160                       while(numbits >= 8) { \
     161                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
     162#define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \
     163                       if(b < 0.0) \
     164                       { \
     165                         s = 1; \
     166                         i = GLONASSTOINT(long long,(-b)/(c)); \
     167                         if(!i) s = 0; \
     168                       } \
     169                       else \
     170                       { \
     171                         s = 0; \
     172                         i = GLONASSTOINT(long long,(b)/(c)); \
     173                       } \
     174                       GLONASSADDBITS(1,s) \
     175                       GLONASSADDBITS(a-1,i)}
     176
     177// RTCM3 Galileo EPH encoding
     178//////////////////////////////////////////////////////////
     179#define GALILEOTOINT(type, value) static_cast<type>(round(value))
     180#define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
     181                       |(GALILEOTOINT(long long,b)&((1LL<<a)-1)); \
     182                       numbits += (a); \
     183                       while(numbits >= 8) { \
     184                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
     185#define GALILEOADDBITSFLOAT(a,b,c) {long long i = GALILEOTOINT(long long,(b)/(c)); \
     186                             GALILEOADDBITS(a,i)};
     187
     188// RTCM3 SBAS EPH encoding
     189//////////////////////////////////////////////////////////
     190#define SBASTOINT(type, value) static_cast<type>(round(value))
     191#define SBASADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
     192                       |(SBASTOINT(long long,b)&((1ULL<<a)-1)); \
     193                       numbits += (a); \
     194                       while(numbits >= 8) { \
     195                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
     196#define SBASADDBITSFLOAT(a,b,c) {long long i = SBASTOINT(long long,(b)/(c)); \
     197                             SBASADDBITS(a,i)};
     198
     199// RTCM3 BDS EPH encoding
     200//////////////////////////////////////////////////////////
     201#define BDSTOINT(type, value) static_cast<type>(round(value))
     202#define BDSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
     203                       |(BDSTOINT(long long,b)&((1ULL<<a)-1)); \
     204                       numbits += (a); \
     205                       while(numbits >= 8) { \
     206                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
     207#define BDSADDBITSFLOAT(a,b,c) {long long i = BDSTOINT(long long,(b)/(c)); \
     208                             BDSADDBITS(a,i)};
     209
    136210#endif
Note: See TracChangeset for help on using the changeset viewer.