Index: trunk/FACT++/src/ratecontrol.cc
===================================================================
--- trunk/FACT++/src/ratecontrol.cc	(revision 16777)
+++ trunk/FACT++/src/ratecontrol.cc	(revision 16778)
@@ -131,5 +131,5 @@
 
     // RETUNR VALUE
-    void Step(int idx, float step)
+    int32_t Step(int idx, float step)
     {
         uint16_t diff = fThresholds[idx]+int16_t(truncf(step));
@@ -138,5 +138,5 @@
 
         if (diff==fThresholds[idx])
-            return;
+            return -1;
 
         if (fVerbose)
@@ -147,8 +147,10 @@
         }
 
-        const uint32_t val[2] = { idx,  diff };
-        Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);
+        //const uint32_t val[2] = { idx,  diff };
+        //Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);
 
         fBlock[idx/4] = true;
+
+        return diff;
     }
 
@@ -186,4 +188,6 @@
         if (fVerbose)
             Out() << Tools::Form("Board: Med=%3.1f +- %3.1f   Patch: Med=%3.1f +- %3.1f", mb, db, mp, dp) << endl;
+
+        vector<int32_t> newth(160, -1);
 
         for (int i=0; i<40; i++)
@@ -225,5 +229,5 @@
                     const float step = (log10(sdata.fPatchRate[i*4+j])-log10(mp+3.5*dp))/0.039;
                     //  * (dif-5)/dif
-                    Step(i*4+j, step);
+                    newth[i*4+j] = Step(i*4+j, step);
                     continue;
                 }
@@ -233,14 +237,19 @@
                 {
                     const float step = (log10(sdata.fPatchRate[i*4+j])-log10(mp+3.5*dp))/0.039;
-                    Step(i*4+j, step);
+                    newth[i*4+j] = Step(i*4+j, step);
                     continue;
                 }
 
                 const float step =  -1.5*(log10(mp+dp)-log10(mp))/0.039;
-                Step(i*4+j, step);
+                newth[i*4+j] = Step(i*4+j, step);
             }
-            // SET_SELECTED_THRESHOLDS
-
-        }
+        }
+
+        // WARNING: By _not_ updating fThresholds here, we assume
+        // the the returned static data block is received before the
+        // next update. If not, we will just skip these patches (block
+        // condition) and send the same update next time again.
+        if (std::count(newth.begin(), newth.end(), -1)!=160)
+            Dim::SendCommandNB("FTM_CONTROL/SET_SELECTED_THRESHOLDS", newth);
     }
 
@@ -535,5 +544,5 @@
         vector<int32_t> val(160, fThresholdMin);
         std::copy(fThresholds.begin(), fThresholds.end(), val.begin());
-        Dim::SendCommandNB("FTM_CONTROL/SET_ALL_THRESHOLDS", val.data(), val.size()*sizeof(int32_t));
+        Dim::SendCommandNB("FTM_CONTROL/SET_ALL_THRESHOLDS", val);
 
 
