Index: trunk/BNC/RTCM3/clock_orbit_rtcm.c
===================================================================
--- trunk/BNC/RTCM3/clock_orbit_rtcm.c	(revision 1808)
+++ trunk/BNC/RTCM3/clock_orbit_rtcm.c	(revision 1809)
@@ -3,5 +3,5 @@
         Name:           clock_orbit_rtcm.c
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.c,v 1.3 2009/02/12 11:56:16 stoecker Exp $
+        Version:        $Id: clock_orbit_rtcm.c,v 1.4 2009/04/24 08:36:34 stoecker Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -93,18 +93,18 @@
 
 /* defined values */
-#define T_DELTA_RADIAL(a)                SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_ALONG_TRACK(a)           SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_CROSS_TRACK(a)           SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_DOT_RADIAL(a)            SCALEADDBITS(21, 1000000.0, a)
-#define T_DELTA_DOT_ALONG_TRACK(a)       SCALEADDBITS(21, 1000000.0, a)
-#define T_DELTA_DOT_CROSS_TRACK(a)       SCALEADDBITS(21, 1000000.0, a)
+#define T_DELTA_RADIAL(a)                SCALEADDBITS(22,    10000.0, a)
+#define T_DELTA_ALONG_TRACK(a)           SCALEADDBITS(20,     2500.0, a)
+#define T_DELTA_CROSS_TRACK(a)           SCALEADDBITS(20,     2500.0, a)
+#define T_DELTA_DOT_RADIAL(a)            SCALEADDBITS(21,  1000000.0, a)
+#define T_DELTA_DOT_ALONG_TRACK(a)       SCALEADDBITS(19,   250000.0, a)
+#define T_DELTA_DOT_CROSS_TRACK(a)       SCALEADDBITS(19,   250000.0, a)
 #define T_DELTA_DOT_DOT_RADIAL(a)        SCALEADDBITS(27, 50000000.0, a)
-#define T_DELTA_DOT_DOT_ALONG_TRACK(a)   SCALEADDBITS(27, 50000000.0, a)
-#define T_DELTA_DOT_DOT_CROSS_TRACK(a)   SCALEADDBITS(27, 50000000.0, a)
+#define T_DELTA_DOT_DOT_ALONG_TRACK(a)   SCALEADDBITS(25, 12500000.0, a)
+#define T_DELTA_DOT_DOT_CROSS_TRACK(a)   SCALEADDBITS(25, 12500000.0, a)
 #define T_SATELLITE_REFERENCE_POINT(a)   ADDBITS(1, a)
 
 #define T_SATELLITE_REFERENCE_DATUM(a)   ADDBITS(1, a)
-#define T_DELTA_CLOCK_C0(a)              SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_CLOCK_C1(a)              SCALEADDBITS(21, 1000000.0, a)
+#define T_DELTA_CLOCK_C0(a)              SCALEADDBITS(22,    10000.0, a)
+#define T_DELTA_CLOCK_C1(a)              SCALEADDBITS(21,  1000000.0, a)
 #define T_DELTA_CLOCK_C2(a)              SCALEADDBITS(27, 50000000.0, a)
 #define T_NO_OF_CODE_BIASES(a)           ADDBITS(5, a)
@@ -112,5 +112,5 @@
 #define T_GLONASS_SIGNAL_IDENTIFIER(a)   ADDBITS(5, a)
 #define T_GALILEO_SIGNAL_IDENTIFIER(a)   ADDBITS(5, a)
-#define T_CODE_BIAS(a)                   SCALEADDBITS(14, 100.0, a)
+#define T_CODE_BIAS(a)                   SCALEADDBITS(14,      100.0, a)
 #define T_GLONASS_SATELLITE_ID(a)        ADDBITS(5, a)
 
@@ -120,5 +120,5 @@
 #define T_MULTIPLE_MESSAGE_INDICATOR(a)  ADDBITS(1, a)
 #define T_SSR_URA(a)                     ADDBITS(4, a)
-#define T_HR_CLOCK_CORRECTION(a)         SCALEADDBITS(22, 10000.0, a)
+#define T_HR_CLOCK_CORRECTION(a)         SCALEADDBITS(22,    10000.0, a)
 #define T_SSR_UPDATE_INTERVAL(a)         ADDBITS(4, a)
 
@@ -475,5 +475,5 @@
   while((a) > numbits) \
   { \
-    if(!size--) return GCOBR_SHORTBUFFER; \
+    if(!size--) return GCOBR_SHORTMESSAGE; \
     bitbuffer = (bitbuffer<<8)|((unsigned char)*(buffer++)); \
     numbits += 8; \
@@ -514,12 +514,12 @@
 /* defined values */
 #define G_DELTA_RADIAL(a)                GETFLOATSIGN(a, 22, 1/10000.0)
-#define G_DELTA_ALONG_TRACK(a)           GETFLOATSIGN(a, 22, 1/10000.0)
-#define G_DELTA_CROSS_TRACK(a)           GETFLOATSIGN(a, 22, 1/10000.0)
+#define G_DELTA_ALONG_TRACK(a)           GETFLOATSIGN(a, 20, 1/2500.0)
+#define G_DELTA_CROSS_TRACK(a)           GETFLOATSIGN(a, 20, 1/2500.0)
 #define G_DELTA_DOT_RADIAL(a)            GETFLOATSIGN(a, 21, 1/1000000.0)
-#define G_DELTA_DOT_ALONG_TRACK(a)       GETFLOATSIGN(a, 21, 1/1000000.0)
-#define G_DELTA_DOT_CROSS_TRACK(a)       GETFLOATSIGN(a, 21, 1/1000000.0)
+#define G_DELTA_DOT_ALONG_TRACK(a)       GETFLOATSIGN(a, 19, 1/250000.0)
+#define G_DELTA_DOT_CROSS_TRACK(a)       GETFLOATSIGN(a, 19, 1/250000.0)
 #define G_DELTA_DOT_DOT_RADIAL(a)        GETFLOATSIGN(a, 27, 1/50000000.0)
-#define G_DELTA_DOT_DOT_ALONG_TRACK(a)   GETFLOATSIGN(a, 27, 1/50000000.0)
-#define G_DELTA_DOT_DOT_CROSS_TRACK(a)   GETFLOATSIGN(a, 27, 1/50000000.0)
+#define G_DELTA_DOT_DOT_ALONG_TRACK(a)   GETFLOATSIGN(a, 25, 1/12500000.0)
+#define G_DELTA_DOT_DOT_CROSS_TRACK(a)   GETFLOATSIGN(a, 25, 1/12500000.0)
 #define G_SATELLITE_REFERENCE_POINT(a)   GETBITS(a, 1)
 
@@ -595,6 +595,10 @@
    (((unsigned char)buffer[sizeofrtcmblock+2]))))
     return GCOBR_CRCMISMATCH;
+  size = sizeofrtcmblock; /* reduce size, so overflows are detected */
 
   G_MESSAGE_NUMBER(type)
+#ifdef DEBUG
+fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock);
+#endif
   switch(type)
   {
@@ -611,4 +615,7 @@
       return GCOBR_DATAMISMATCH;
     co->OrbitDataSupplied = 1;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d\n",co->GPSEpochTime,co->UpdateInterval,mmi,co->NumberOfGPSSat);
+#endif
     for(i = 0; i < co->NumberOfGPSSat; ++i)
     {
@@ -626,4 +633,17 @@
       G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
       G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+#ifdef DEBUG
+fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f rp %d rd %d\n",
+co->Sat[i].ID,co->Sat[i].IOD,co->Sat[i].Orbit.DeltaRadial,
+co->Sat[i].Orbit.DeltaAlongTrack,co->Sat[i].Orbit.DeltaCrossTrack,
+co->Sat[i].Orbit.DotDeltaRadial,
+co->Sat[i].Orbit.DotDeltaAlongTrack,
+co->Sat[i].Orbit.DotDeltaCrossTrack,
+co->Sat[i].Orbit.DotDotDeltaRadial,
+co->Sat[i].Orbit.DotDotDeltaAlongTrack,
+co->Sat[i].Orbit.DotDotDeltaCrossTrack,
+co->SatRefPoint,
+co->SatRefDatum);
+#endif
     }
     break;
@@ -1062,4 +1082,9 @@
     return GCOBR_UNKNOWNTYPE;
   }
+#ifdef DEBUG
+for(type = 0; type < size && (unsigned char)buffer[type] != 0xD3; ++type)
+  numbits += 8;
+fprintf(stderr, "numbits left %d\n",numbits);
+#endif
   if(bytesused)
     *bytesused = sizeofrtcmblock+6;
Index: trunk/BNC/RTCM3/clock_orbit_rtcm.h
===================================================================
--- trunk/BNC/RTCM3/clock_orbit_rtcm.h	(revision 1808)
+++ trunk/BNC/RTCM3/clock_orbit_rtcm.h	(revision 1809)
@@ -6,5 +6,5 @@
         Name:           clock_orbit_rtcm.h
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.h,v 1.7 2009/02/27 08:59:55 weber Exp $
+        Version:        $Id: clock_orbit_rtcm.h,v 1.4 2009/04/24 08:36:34 stoecker Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -131,5 +131,6 @@
   GCOBR_SHORTBUFFER = -30,
   GCOBR_MISSINGBITS = -31,
-  GCOBR_MESSAGEEXCEEDSBUFFER = -32
+  GCOBR_MESSAGEEXCEEDSBUFFER = -32,
+  GCOBR_SHORTMESSAGE = -33
 };
 
Index: trunk/BNS/RTCM/clock_orbit_rtcm.c
===================================================================
--- trunk/BNS/RTCM/clock_orbit_rtcm.c	(revision 1808)
+++ trunk/BNS/RTCM/clock_orbit_rtcm.c	(revision 1809)
@@ -3,5 +3,5 @@
         Name:           clock_orbit_rtcm.c
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.c,v 1.9 2009/02/27 08:59:49 weber Exp $
+        Version:        $Id: clock_orbit_rtcm.c,v 1.4 2009/04/24 08:36:34 stoecker Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -93,18 +93,18 @@
 
 /* defined values */
-#define T_DELTA_RADIAL(a)                SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_ALONG_TRACK(a)           SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_CROSS_TRACK(a)           SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_DOT_RADIAL(a)            SCALEADDBITS(21, 1000000.0, a)
-#define T_DELTA_DOT_ALONG_TRACK(a)       SCALEADDBITS(21, 1000000.0, a)
-#define T_DELTA_DOT_CROSS_TRACK(a)       SCALEADDBITS(21, 1000000.0, a)
+#define T_DELTA_RADIAL(a)                SCALEADDBITS(22,    10000.0, a)
+#define T_DELTA_ALONG_TRACK(a)           SCALEADDBITS(20,     2500.0, a)
+#define T_DELTA_CROSS_TRACK(a)           SCALEADDBITS(20,     2500.0, a)
+#define T_DELTA_DOT_RADIAL(a)            SCALEADDBITS(21,  1000000.0, a)
+#define T_DELTA_DOT_ALONG_TRACK(a)       SCALEADDBITS(19,   250000.0, a)
+#define T_DELTA_DOT_CROSS_TRACK(a)       SCALEADDBITS(19,   250000.0, a)
 #define T_DELTA_DOT_DOT_RADIAL(a)        SCALEADDBITS(27, 50000000.0, a)
-#define T_DELTA_DOT_DOT_ALONG_TRACK(a)   SCALEADDBITS(27, 50000000.0, a)
-#define T_DELTA_DOT_DOT_CROSS_TRACK(a)   SCALEADDBITS(27, 50000000.0, a)
+#define T_DELTA_DOT_DOT_ALONG_TRACK(a)   SCALEADDBITS(25, 12500000.0, a)
+#define T_DELTA_DOT_DOT_CROSS_TRACK(a)   SCALEADDBITS(25, 12500000.0, a)
 #define T_SATELLITE_REFERENCE_POINT(a)   ADDBITS(1, a)
 
 #define T_SATELLITE_REFERENCE_DATUM(a)   ADDBITS(1, a)
-#define T_DELTA_CLOCK_C0(a)              SCALEADDBITS(22, 10000.0, a)
-#define T_DELTA_CLOCK_C1(a)              SCALEADDBITS(21, 1000000.0, a)
+#define T_DELTA_CLOCK_C0(a)              SCALEADDBITS(22,    10000.0, a)
+#define T_DELTA_CLOCK_C1(a)              SCALEADDBITS(21,  1000000.0, a)
 #define T_DELTA_CLOCK_C2(a)              SCALEADDBITS(27, 50000000.0, a)
 #define T_NO_OF_CODE_BIASES(a)           ADDBITS(5, a)
@@ -112,5 +112,5 @@
 #define T_GLONASS_SIGNAL_IDENTIFIER(a)   ADDBITS(5, a)
 #define T_GALILEO_SIGNAL_IDENTIFIER(a)   ADDBITS(5, a)
-#define T_CODE_BIAS(a)                   SCALEADDBITS(14, 100.0, a)
+#define T_CODE_BIAS(a)                   SCALEADDBITS(14,      100.0, a)
 #define T_GLONASS_SATELLITE_ID(a)        ADDBITS(5, a)
 
@@ -120,5 +120,5 @@
 #define T_MULTIPLE_MESSAGE_INDICATOR(a)  ADDBITS(1, a)
 #define T_SSR_URA(a)                     ADDBITS(4, a)
-#define T_HR_CLOCK_CORRECTION(a)         SCALEADDBITS(22, 10000.0, a)
+#define T_HR_CLOCK_CORRECTION(a)         SCALEADDBITS(22,    10000.0, a)
 #define T_SSR_UPDATE_INTERVAL(a)         ADDBITS(4, a)
 
@@ -475,5 +475,5 @@
   while((a) > numbits) \
   { \
-    if(!size--) return GCOBR_SHORTBUFFER; \
+    if(!size--) return GCOBR_SHORTMESSAGE; \
     bitbuffer = (bitbuffer<<8)|((unsigned char)*(buffer++)); \
     numbits += 8; \
@@ -514,12 +514,12 @@
 /* defined values */
 #define G_DELTA_RADIAL(a)                GETFLOATSIGN(a, 22, 1/10000.0)
-#define G_DELTA_ALONG_TRACK(a)           GETFLOATSIGN(a, 22, 1/10000.0)
-#define G_DELTA_CROSS_TRACK(a)           GETFLOATSIGN(a, 22, 1/10000.0)
+#define G_DELTA_ALONG_TRACK(a)           GETFLOATSIGN(a, 20, 1/2500.0)
+#define G_DELTA_CROSS_TRACK(a)           GETFLOATSIGN(a, 20, 1/2500.0)
 #define G_DELTA_DOT_RADIAL(a)            GETFLOATSIGN(a, 21, 1/1000000.0)
-#define G_DELTA_DOT_ALONG_TRACK(a)       GETFLOATSIGN(a, 21, 1/1000000.0)
-#define G_DELTA_DOT_CROSS_TRACK(a)       GETFLOATSIGN(a, 21, 1/1000000.0)
+#define G_DELTA_DOT_ALONG_TRACK(a)       GETFLOATSIGN(a, 19, 1/250000.0)
+#define G_DELTA_DOT_CROSS_TRACK(a)       GETFLOATSIGN(a, 19, 1/250000.0)
 #define G_DELTA_DOT_DOT_RADIAL(a)        GETFLOATSIGN(a, 27, 1/50000000.0)
-#define G_DELTA_DOT_DOT_ALONG_TRACK(a)   GETFLOATSIGN(a, 27, 1/50000000.0)
-#define G_DELTA_DOT_DOT_CROSS_TRACK(a)   GETFLOATSIGN(a, 27, 1/50000000.0)
+#define G_DELTA_DOT_DOT_ALONG_TRACK(a)   GETFLOATSIGN(a, 25, 1/12500000.0)
+#define G_DELTA_DOT_DOT_CROSS_TRACK(a)   GETFLOATSIGN(a, 25, 1/12500000.0)
 #define G_SATELLITE_REFERENCE_POINT(a)   GETBITS(a, 1)
 
@@ -595,6 +595,10 @@
    (((unsigned char)buffer[sizeofrtcmblock+2]))))
     return GCOBR_CRCMISMATCH;
+  size = sizeofrtcmblock; /* reduce size, so overflows are detected */
 
   G_MESSAGE_NUMBER(type)
+#ifdef DEBUG
+fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock);
+#endif
   switch(type)
   {
@@ -611,4 +615,7 @@
       return GCOBR_DATAMISMATCH;
     co->OrbitDataSupplied = 1;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d\n",co->GPSEpochTime,co->UpdateInterval,mmi,co->NumberOfGPSSat);
+#endif
     for(i = 0; i < co->NumberOfGPSSat; ++i)
     {
@@ -626,4 +633,17 @@
       G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
       G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+#ifdef DEBUG
+fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f rp %d rd %d\n",
+co->Sat[i].ID,co->Sat[i].IOD,co->Sat[i].Orbit.DeltaRadial,
+co->Sat[i].Orbit.DeltaAlongTrack,co->Sat[i].Orbit.DeltaCrossTrack,
+co->Sat[i].Orbit.DotDeltaRadial,
+co->Sat[i].Orbit.DotDeltaAlongTrack,
+co->Sat[i].Orbit.DotDeltaCrossTrack,
+co->Sat[i].Orbit.DotDotDeltaRadial,
+co->Sat[i].Orbit.DotDotDeltaAlongTrack,
+co->Sat[i].Orbit.DotDotDeltaCrossTrack,
+co->SatRefPoint,
+co->SatRefDatum);
+#endif
     }
     break;
@@ -1062,4 +1082,9 @@
     return GCOBR_UNKNOWNTYPE;
   }
+#ifdef DEBUG
+for(type = 0; type < size && (unsigned char)buffer[type] != 0xD3; ++type)
+  numbits += 8;
+fprintf(stderr, "numbits left %d\n",numbits);
+#endif
   if(bytesused)
     *bytesused = sizeofrtcmblock+6;
Index: trunk/BNS/RTCM/clock_orbit_rtcm.h
===================================================================
--- trunk/BNS/RTCM/clock_orbit_rtcm.h	(revision 1808)
+++ trunk/BNS/RTCM/clock_orbit_rtcm.h	(revision 1809)
@@ -6,5 +6,5 @@
         Name:           clock_orbit_rtcm.h
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.h,v 1.8 2009/03/06 15:59:53 weber Exp $
+        Version:        $Id: clock_orbit_rtcm.h,v 1.4 2009/04/24 08:36:34 stoecker Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -131,5 +131,6 @@
   GCOBR_SHORTBUFFER = -30,
   GCOBR_MISSINGBITS = -31,
-  GCOBR_MESSAGEEXCEEDSBUFFER = -32
+  GCOBR_MESSAGEEXCEEDSBUFFER = -32,
+  GCOBR_SHORTMESSAGE = -33
 };
 
