Index: trunk/BNC/RTCM3/RTCM3coDecoder.cpp
===================================================================
--- trunk/BNC/RTCM3/RTCM3coDecoder.cpp	(revision 1841)
+++ trunk/BNC/RTCM3/RTCM3coDecoder.cpp	(revision 1842)
@@ -144,5 +144,6 @@
     else if (irc < 0) {    // error  - skip 1 byte and retry
       memset(&_co, 0, sizeof(_co));
-      _buffer = _buffer.mid(1);
+      memset(&_bias, 0, sizeof(_bias));
+      _buffer = _buffer.mid(bytesused ? bytesused : 1);
     }
 
@@ -150,5 +151,5 @@
       _buffer = _buffer.mid(bytesused);
 
-      if (irc == GCOBR_OK) { 
+      if (irc == GCOBR_OK) {
         reopen();
 
@@ -173,5 +174,5 @@
         // Correction Epoch from Glonass Epoch
         // -----------------------------------
-        else {
+        else if (_co.NumberOfGLONASSSat > 0){
 
           // Second of day (GPS time) from Glonass Epoch
@@ -229,4 +230,5 @@
         retCode = success;
         memset(&_co, 0, sizeof(_co));
+        memset(&_bias, 0, sizeof(_bias));
       }
     }
Index: trunk/BNC/RTCM3/clock_orbit_rtcm.c
===================================================================
--- trunk/BNC/RTCM3/clock_orbit_rtcm.c	(revision 1841)
+++ trunk/BNC/RTCM3/clock_orbit_rtcm.c	(revision 1842)
@@ -3,5 +3,5 @@
         Name:           clock_orbit_rtcm.c
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.c,v 1.7 2009/05/12 13:19:03 stoecker Exp $
+        Version:        $Id: clock_orbit_rtcm.c,v 1.14 2009/05/12 22:22:45 weber Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -573,4 +573,8 @@
     return GCOBR_SHORTBUFFER;
 
+#ifdef DEBUG
+fprintf(stderr, "GetClockOrbitBias START: size %d, numbits %d\n",size, numbits);
+#endif
+
   G_HEADER(h)
   G_RESERVEDH(rs)
@@ -605,5 +609,6 @@
     co->OrbitDataSupplied |= 1;
 #ifdef DEBUG
-fprintf(stderr, "epochtime %d ui %d mmi %d sats %d\n",co->GPSEpochTime,co->UpdateInterval,mmi,co->NumberOfGPSSat);
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GPSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGPSSat,nums);
 #endif
     for(i = 0; i < nums; ++i)
@@ -653,4 +658,8 @@
     G_NO_OF_SATELLITES(nums)
     co->ClockDataSupplied |= 1;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GPSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGPSSat,nums);
+#endif
     for(i = 0; i < nums; ++i)
     {
@@ -665,4 +674,9 @@
       G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
       G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
+#ifdef DEBUG
+fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
+co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
+co->Sat[pos].Clock.DeltaA2);
+#endif
     }
     break;
@@ -755,14 +769,17 @@
     G_NO_OF_SATELLITES(nums)
     co->OrbitDataSupplied |= 2;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GLONASSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums);
+#endif
     for(i = 0; i < nums; ++i)
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
-      G_GLONASS_SATELLITE_ID(co->Sat[pos].ID)
       G_GLONASS_IOD(co->Sat[pos].IOD)
       G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
@@ -777,4 +794,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[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
+co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
+co->Sat[pos].Orbit.DotDeltaRadial,
+co->Sat[pos].Orbit.DotDeltaAlongTrack,
+co->Sat[pos].Orbit.DotDeltaCrossTrack,
+co->Sat[pos].Orbit.DotDotDeltaRadial,
+co->Sat[pos].Orbit.DotDotDeltaAlongTrack,
+co->Sat[pos].Orbit.DotDotDeltaCrossTrack,
+co->SatRefPoint,
+co->SatRefDatum);
+#endif
     }
     break;
@@ -787,11 +817,15 @@
     G_NO_OF_SATELLITES(nums)
     co->ClockDataSupplied |= 2;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GLONASSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums);
+#endif
     for(i = 0; i < nums; ++i)
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -799,4 +833,9 @@
       G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
       G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
+#ifdef DEBUG
+fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
+co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
+co->Sat[pos].Clock.DeltaA2);
+#endif
     }
     break;
@@ -813,8 +852,8 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -846,8 +885,8 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -866,8 +905,8 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -877,6 +916,6 @@
   case BTYPE_GPS:
     if(!b) return GCOBR_NOBIASPARAMETER;
-    G_GPS_EPOCH_TIME(b->GPSEpochTime, co->NumberOfGPSSat)
-    G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+    G_GPS_EPOCH_TIME(b->GPSEpochTime, b->NumberOfGPSSat)
+    G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
     G_RESERVED5
@@ -885,9 +924,9 @@
     {
       G_GPS_SATELLITE_ID(id)
-      for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = 0; pos < b->NumberOfGPSSat && b->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;
-      co->Sat[pos].ID = id;
+      else if(pos == b->NumberOfGPSSat) ++b->NumberOfGPSSat;
+      b->Sat[pos].ID = id;
 
       G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)
@@ -901,6 +940,6 @@
   case BTYPE_GLONASS:
     if(!b) return GCOBR_NOBIASPARAMETER;
-    G_GPS_EPOCH_TIME(b->GLONASSEpochTime, co->NumberOfGLONASSSat)
-    G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+    G_GLONASS_EPOCH_TIME(b->GLONASSEpochTime, b->NumberOfGLONASSSat)
+    G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
     G_RESERVED5
@@ -909,9 +948,9 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < b->NumberOfGLONASSSat && b->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
-      co->Sat[pos].ID = id;
+      else if(pos == b->NumberOfGLONASSSat) ++b->NumberOfGLONASSSat;
+      b->Sat[pos].ID = id;
 
       G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)
@@ -924,8 +963,10 @@
     break;
   default:
+    if(bytesused)
+      *bytesused = sizeofrtcmblock+6;
     return GCOBR_UNKNOWNTYPE;
   }
 #ifdef DEBUG
-for(type = 0; type < size && (unsigned char)buffer[type] != 0xD3; ++type)
+for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type)
   numbits += 8;
 fprintf(stderr, "numbits left %d\n",numbits);
Index: trunk/BNC/RTCM3/clock_orbit_rtcm.h
===================================================================
--- trunk/BNC/RTCM3/clock_orbit_rtcm.h	(revision 1841)
+++ trunk/BNC/RTCM3/clock_orbit_rtcm.h	(revision 1842)
@@ -6,5 +6,5 @@
         Name:           clock_orbit_rtcm.h
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.h,v 1.5 2009/05/12 13:19:03 stoecker Exp $
+        Version:        $Id: clock_orbit_rtcm.h,v 1.10 2009/05/12 22:23:17 weber Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -122,4 +122,5 @@
   GCOBR_UNKNOWNDATA = -2,
   GCOBR_CRCMISMATCH = -3,
+  GCOBR_SHORTMESSAGE = -4,
   /* failed to do the work */
   GCOBR_NOCLOCKORBITPARAMETER = -10,
@@ -130,8 +131,5 @@
   /* not enough data - can decode the block completely */
   GCOBR_SHORTBUFFER = -30,
-  GCOBR_MISSINGBITS = -31,
-  GCOBR_MESSAGEEXCEEDSBUFFER = -32,
-  GCOBR_SHORTMESSAGE = -33
-};
+  GCOBR_MESSAGEEXCEEDSBUFFER = -31};
 
 /* NOTE: When an error message has been emitted, the output structures may have been modified. Make a copy of the previous variant before calling the
Index: trunk/clock_and_orbit/clock_orbit_rtcm.c
===================================================================
--- trunk/clock_and_orbit/clock_orbit_rtcm.c	(revision 1841)
+++ trunk/clock_and_orbit/clock_orbit_rtcm.c	(revision 1842)
@@ -3,5 +3,5 @@
         Name:           clock_orbit_rtcm.c
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.c,v 1.13 2009/05/06 14:02:39 stoecker Exp $
+        Version:        $Id: clock_orbit_rtcm.c,v 1.15 2009/05/14 13:24:13 stoecker Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -573,4 +573,8 @@
     return GCOBR_SHORTBUFFER;
 
+#ifdef DEBUG
+fprintf(stderr, "GetClockOrbitBias START: size %d, numbits %d\n",size, numbits);
+#endif
+
   G_HEADER(h)
   G_RESERVEDH(rs)
@@ -605,5 +609,6 @@
     co->OrbitDataSupplied |= 1;
 #ifdef DEBUG
-fprintf(stderr, "epochtime %d ui %d mmi %d sats %d\n",co->GPSEpochTime,co->UpdateInterval,mmi,co->NumberOfGPSSat);
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GPSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGPSSat,nums);
 #endif
     for(i = 0; i < nums; ++i)
@@ -653,4 +658,8 @@
     G_NO_OF_SATELLITES(nums)
     co->ClockDataSupplied |= 1;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GPSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGPSSat,nums);
+#endif
     for(i = 0; i < nums; ++i)
     {
@@ -665,4 +674,9 @@
       G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
       G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
+#ifdef DEBUG
+fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
+co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
+co->Sat[pos].Clock.DeltaA2);
+#endif
     }
     break;
@@ -755,14 +769,17 @@
     G_NO_OF_SATELLITES(nums)
     co->OrbitDataSupplied |= 2;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GLONASSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums);
+#endif
     for(i = 0; i < nums; ++i)
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
-      G_GLONASS_SATELLITE_ID(co->Sat[pos].ID)
       G_GLONASS_IOD(co->Sat[pos].IOD)
       G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
@@ -777,4 +794,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[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
+co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
+co->Sat[pos].Orbit.DotDeltaRadial,
+co->Sat[pos].Orbit.DotDeltaAlongTrack,
+co->Sat[pos].Orbit.DotDeltaCrossTrack,
+co->Sat[pos].Orbit.DotDotDeltaRadial,
+co->Sat[pos].Orbit.DotDotDeltaAlongTrack,
+co->Sat[pos].Orbit.DotDotDeltaCrossTrack,
+co->SatRefPoint,
+co->SatRefDatum);
+#endif
     }
     break;
@@ -787,11 +817,15 @@
     G_NO_OF_SATELLITES(nums)
     co->ClockDataSupplied |= 2;
+#ifdef DEBUG
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GLONASSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums);
+#endif
     for(i = 0; i < nums; ++i)
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -799,4 +833,9 @@
       G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
       G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
+#ifdef DEBUG
+fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
+co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
+co->Sat[pos].Clock.DeltaA2);
+#endif
     }
     break;
@@ -813,8 +852,8 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -846,8 +885,8 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -866,8 +905,8 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
+      else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
       co->Sat[pos].ID = id;
 
@@ -877,6 +916,6 @@
   case BTYPE_GPS:
     if(!b) return GCOBR_NOBIASPARAMETER;
-    G_GPS_EPOCH_TIME(b->GPSEpochTime, co->NumberOfGPSSat)
-    G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+    G_GPS_EPOCH_TIME(b->GPSEpochTime, b->NumberOfGPSSat)
+    G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
     G_RESERVED5
@@ -885,9 +924,9 @@
     {
       G_GPS_SATELLITE_ID(id)
-      for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = 0; pos < b->NumberOfGPSSat && b->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;
-      co->Sat[pos].ID = id;
+      else if(pos == b->NumberOfGPSSat) ++b->NumberOfGPSSat;
+      b->Sat[pos].ID = id;
 
       G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)
@@ -901,6 +940,6 @@
   case BTYPE_GLONASS:
     if(!b) return GCOBR_NOBIASPARAMETER;
-    G_GPS_EPOCH_TIME(b->GLONASSEpochTime, co->NumberOfGLONASSSat)
-    G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+    G_GLONASS_EPOCH_TIME(b->GLONASSEpochTime, b->NumberOfGLONASSSat)
+    G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
     G_RESERVED5
@@ -909,9 +948,9 @@
     {
       G_GLONASS_SATELLITE_ID(id)
-      for(pos = CLOCKORBIT_NUMGPS; pos < co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)
+      for(pos = CLOCKORBIT_NUMGPS; pos < b->NumberOfGLONASSSat && b->Sat[pos].ID != id; ++pos)
         ;
       if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;
-      else if(pos == co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;
-      co->Sat[pos].ID = id;
+      else if(pos == b->NumberOfGLONASSSat) ++b->NumberOfGLONASSSat;
+      b->Sat[pos].ID = id;
 
       G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)
@@ -924,8 +963,10 @@
     break;
   default:
+    if(bytesused)
+      *bytesused = sizeofrtcmblock+6;
     return GCOBR_UNKNOWNTYPE;
   }
 #ifdef DEBUG
-for(type = 0; type < size && (unsigned char)buffer[type] != 0xD3; ++type)
+for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type)
   numbits += 8;
 fprintf(stderr, "numbits left %d\n",numbits);
Index: trunk/clock_and_orbit/clock_orbit_rtcm.h
===================================================================
--- trunk/clock_and_orbit/clock_orbit_rtcm.h	(revision 1841)
+++ trunk/clock_and_orbit/clock_orbit_rtcm.h	(revision 1842)
@@ -6,5 +6,5 @@
         Name:           clock_orbit_rtcm.h
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.h,v 1.9 2009/04/24 09:19:10 weber Exp $
+        Version:        $Id: clock_orbit_rtcm.h,v 1.11 2009/05/14 13:24:13 stoecker Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -122,4 +122,5 @@
   GCOBR_UNKNOWNDATA = -2,
   GCOBR_CRCMISMATCH = -3,
+  GCOBR_SHORTMESSAGE = -4,
   /* failed to do the work */
   GCOBR_NOCLOCKORBITPARAMETER = -10,
@@ -130,8 +131,5 @@
   /* not enough data - can decode the block completely */
   GCOBR_SHORTBUFFER = -30,
-  GCOBR_MISSINGBITS = -31,
-  GCOBR_MESSAGEEXCEEDSBUFFER = -32,
-  GCOBR_SHORTMESSAGE = -33
-};
+  GCOBR_MESSAGEEXCEEDSBUFFER = -31};
 
 /* NOTE: When an error message has been emitted, the output structures may have been modified. Make a copy of the previous variant before calling the
