Changeset 7053 in ntrip for trunk/BNC/src/RTCM3/ephEncoder.cpp
- Timestamp:
- Jul 16, 2015, 9:43:15 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/RTCM3/ephEncoder.cpp
r6869 r7053 4 4 using namespace std; 5 5 6 // Returns CRC247 ////////////////////////////////////////////////////////////////////////////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 }22 6 23 7 // build up RTCM3 for GPS 24 8 //////////////////////////////////////////////////////////////////////////// 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 36 9 int t_ephEncoder::RTCM3(const t_ephGPS& eph, unsigned char *buffer) { 37 10 … … 138 111 // build up RTCM3 for GLONASS 139 112 //////////////////////////////////////////////////////////////////////////// 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 162 113 int t_ephEncoder::RTCM3(const t_ephGlo& eph, unsigned char *buffer) 163 114 { … … 225 176 // build up RTCM3 for Galileo 226 177 //////////////////////////////////////////////////////////////////////////// 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 237 178 int t_ephEncoder::RTCM3(const t_ephGal& eph, unsigned char *buffer) { 238 179 int size = 0; … … 309 250 // build up RTCM3 for SBAS 310 251 //////////////////////////////////////////////////////////////////////////// 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 321 252 int t_ephEncoder::RTCM3(const t_ephSBAS& eph, unsigned char* buffer) { 322 253 int size = 0; … … 358 289 // build up RTCM3 for BDS 359 290 //////////////////////////////////////////////////////////////////////////// 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 370 291 int t_ephEncoder::RTCM3(const t_ephBDS& eph, unsigned char* buffer) { 371 292 int size = 0; … … 418 339 return size; 419 340 } 341
Note:
See TracChangeset
for help on using the changeset viewer.