Changeset 7053 in ntrip
- Timestamp:
- Jul 16, 2015, 9:43:15 AM (10 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 3 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 -
trunk/BNC/src/bncutils.cpp
r6812 r7053 867 867 return (type == t_eph::Galileo) ? 255 : 15; 868 868 } 869 870 // Returns CRC24 871 //////////////////////////////////////////////////////////////////////////// 872 unsigned long CRC24(long size, const unsigned char *buf) { 873 unsigned long crc = 0; 874 int ii; 875 while (size--) { 876 crc ^= (*buf++) << (16); 877 for(ii = 0; ii < 8; ii++) { 878 crc <<= 1; 879 if (crc & 0x1000000) { 880 crc ^= 0x01864cfb; 881 } 882 } 883 } 884 return crc; 885 } 886 -
trunk/BNC/src/bncutils.h
r6812 r7053 134 134 int indexFromAccuracy(double accuracy, t_eph::e_type type); 135 135 136 137 // CRC24Q checksum calculation function (only full bytes supported). 138 /////////////////////////////////////////////////////////////////// 139 unsigned 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 136 210 #endif
Note:
See TracChangeset
for help on using the changeset viewer.