Index: trunk/BNC/src/RTCM3/ephEncoder.cpp
===================================================================
--- trunk/BNC/src/RTCM3/ephEncoder.cpp	(revision 7052)
+++ trunk/BNC/src/RTCM3/ephEncoder.cpp	(revision 7053)
@@ -4,34 +4,7 @@
 using namespace std;
 
-// Returns CRC24
-////////////////////////////////////////////////////////////////////////////
-static unsigned long CRC24(long size, const unsigned char *buf) {
-  unsigned long crc = 0;
-  int ii;
-  while (size--) {
-    crc ^= (*buf++) << (16);
-    for(ii = 0; ii < 8; ii++) {
-      crc <<= 1;
-      if (crc & 0x1000000) {
-        crc ^= 0x01864cfb;
-      }
-    }
-  }
-  return crc;
-}
 
 // build up RTCM3 for GPS
 ////////////////////////////////////////////////////////////////////////////
-#define GPSTOINT(type, value) static_cast<type>(round(value))
-
-#define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
-                       |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \
-                       numbits += (a); \
-                       while(numbits >= 8) { \
-                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
-
-#define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \
-                             GPSADDBITS(a,i)};
-
 int t_ephEncoder::RTCM3(const t_ephGPS& eph, unsigned char *buffer) {
 
@@ -138,26 +111,4 @@
 // build up RTCM3 for GLONASS
 ////////////////////////////////////////////////////////////////////////////
-#define GLONASSTOINT(type, value) static_cast<type>(round(value))
-
-#define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
-                       |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \
-                       numbits += (a); \
-                       while(numbits >= 8) { \
-                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
-#define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \
-                       if(b < 0.0) \
-                       { \
-                         s = 1; \
-                         i = GLONASSTOINT(long long,(-b)/(c)); \
-                         if(!i) s = 0; \
-                       } \
-                       else \
-                       { \
-                         s = 0; \
-                         i = GLONASSTOINT(long long,(b)/(c)); \
-                       } \
-                       GLONASSADDBITS(1,s) \
-                       GLONASSADDBITS(a-1,i)}
-
 int t_ephEncoder::RTCM3(const t_ephGlo& eph, unsigned char *buffer)
 {
@@ -225,14 +176,4 @@
 // build up RTCM3 for Galileo
 ////////////////////////////////////////////////////////////////////////////
-#define GALILEOTOINT(type, value) static_cast<type>(round(value))
-
-#define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
-                       |(GALILEOTOINT(long long,b)&((1LL<<a)-1)); \
-                       numbits += (a); \
-                       while(numbits >= 8) { \
-                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
-#define GALILEOADDBITSFLOAT(a,b,c) {long long i = GALILEOTOINT(long long,(b)/(c)); \
-                             GALILEOADDBITS(a,i)};
-
 int t_ephEncoder::RTCM3(const t_ephGal& eph, unsigned char *buffer) {
   int size = 0;
@@ -309,14 +250,4 @@
 // build up RTCM3 for SBAS
 ////////////////////////////////////////////////////////////////////////////
-#define SBASTOINT(type, value) static_cast<type>(round(value))
-
-#define SBASADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
-                       |(SBASTOINT(long long,b)&((1ULL<<a)-1)); \
-                       numbits += (a); \
-                       while(numbits >= 8) { \
-                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
-#define SBASADDBITSFLOAT(a,b,c) {long long i = SBASTOINT(long long,(b)/(c)); \
-                             SBASADDBITS(a,i)};
-
 int t_ephEncoder::RTCM3(const t_ephSBAS& eph, unsigned char* buffer) {
   int size = 0;
@@ -358,14 +289,4 @@
 // build up RTCM3 for BDS
 ////////////////////////////////////////////////////////////////////////////
-#define BDSTOINT(type, value) static_cast<type>(round(value))
-
-#define BDSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
-                       |(BDSTOINT(long long,b)&((1ULL<<a)-1)); \
-                       numbits += (a); \
-                       while(numbits >= 8) { \
-                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
-#define BDSADDBITSFLOAT(a,b,c) {long long i = BDSTOINT(long long,(b)/(c)); \
-                             BDSADDBITS(a,i)};
-
 int t_ephEncoder::RTCM3(const t_ephBDS& eph, unsigned char* buffer) {
   int size = 0;
@@ -418,2 +339,3 @@
   return size;
 }
+
Index: trunk/BNC/src/bncutils.cpp
===================================================================
--- trunk/BNC/src/bncutils.cpp	(revision 7052)
+++ trunk/BNC/src/bncutils.cpp	(revision 7053)
@@ -867,2 +867,20 @@
   return (type == t_eph::Galileo) ? 255 : 15;
 }
+
+// Returns CRC24
+////////////////////////////////////////////////////////////////////////////
+unsigned long CRC24(long size, const unsigned char *buf) {
+  unsigned long crc = 0;
+  int ii;
+  while (size--) {
+    crc ^= (*buf++) << (16);
+    for(ii = 0; ii < 8; ii++) {
+      crc <<= 1;
+      if (crc & 0x1000000) {
+        crc ^= 0x01864cfb;
+      }
+    }
+  }
+  return crc;
+}
+
Index: trunk/BNC/src/bncutils.h
===================================================================
--- trunk/BNC/src/bncutils.h	(revision 7052)
+++ trunk/BNC/src/bncutils.h	(revision 7053)
@@ -134,3 +134,77 @@
 int          indexFromAccuracy(double accuracy, t_eph::e_type type);
 
+
+// CRC24Q checksum calculation function (only full bytes supported).
+///////////////////////////////////////////////////////////////////
+unsigned long CRC24(long size, const unsigned char *buf);
+
+// RTCM3 GPS EPH encoding
+//////////////////////////////////////////////////////////
+#define GPSTOINT(type, value) static_cast<type>(round(value))
+
+#define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
+                       |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \
+                       numbits += (a); \
+                       while(numbits >= 8) { \
+                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
+
+#define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \
+                             GPSADDBITS(a,i)};
+
+// RTCM3 GLONASS EPH encoding
+//////////////////////////////////////////////////////////
+#define GLONASSTOINT(type, value) static_cast<type>(round(value))
+#define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
+                       |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \
+                       numbits += (a); \
+                       while(numbits >= 8) { \
+                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
+#define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \
+                       if(b < 0.0) \
+                       { \
+                         s = 1; \
+                         i = GLONASSTOINT(long long,(-b)/(c)); \
+                         if(!i) s = 0; \
+                       } \
+                       else \
+                       { \
+                         s = 0; \
+                         i = GLONASSTOINT(long long,(b)/(c)); \
+                       } \
+                       GLONASSADDBITS(1,s) \
+                       GLONASSADDBITS(a-1,i)}
+
+// RTCM3 Galileo EPH encoding
+//////////////////////////////////////////////////////////
+#define GALILEOTOINT(type, value) static_cast<type>(round(value))
+#define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
+                       |(GALILEOTOINT(long long,b)&((1LL<<a)-1)); \
+                       numbits += (a); \
+                       while(numbits >= 8) { \
+                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
+#define GALILEOADDBITSFLOAT(a,b,c) {long long i = GALILEOTOINT(long long,(b)/(c)); \
+                             GALILEOADDBITS(a,i)};
+
+// RTCM3 SBAS EPH encoding
+//////////////////////////////////////////////////////////
+#define SBASTOINT(type, value) static_cast<type>(round(value))
+#define SBASADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
+                       |(SBASTOINT(long long,b)&((1ULL<<a)-1)); \
+                       numbits += (a); \
+                       while(numbits >= 8) { \
+                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
+#define SBASADDBITSFLOAT(a,b,c) {long long i = SBASTOINT(long long,(b)/(c)); \
+                             SBASADDBITS(a,i)};
+
+// RTCM3 BDS EPH encoding
+//////////////////////////////////////////////////////////
+#define BDSTOINT(type, value) static_cast<type>(round(value))
+#define BDSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
+                       |(BDSTOINT(long long,b)&((1ULL<<a)-1)); \
+                       numbits += (a); \
+                       while(numbits >= 8) { \
+                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
+#define BDSADDBITSFLOAT(a,b,c) {long long i = BDSTOINT(long long,(b)/(c)); \
+                             BDSADDBITS(a,i)};
+
 #endif
