Index: /trunk/FACT++/src/fadctrl.cc
===================================================================
--- /trunk/FACT++/src/fadctrl.cc	(revision 10862)
+++ /trunk/FACT++/src/fadctrl.cc	(revision 10863)
@@ -66,4 +66,5 @@
     }
 
+    /*
     virtual void UpdateChannelHeader(int i)
     {
@@ -73,4 +74,34 @@
 
         Out() << fChannelHeader[i];
+        if (fIsHexOutput)
+            Out() << Converter::GetHex<uint16_t>(fChannelHeader, 16) << endl;
+    }
+    */
+
+    virtual void UpdateChannelHeaders()
+    {
+        // emit service with trigger counter from header
+        if (!fIsVerbose)
+            return;
+
+        Out() << dec << endl;
+
+        Out() << kBold << "ID: Crate=" << fEventHeader.Crate() << " Board=" << fEventHeader.Board() << endl;
+        for (unsigned int c=0; c<FAD::kNumChips; c++)
+        {
+            Out() << "ReadoutWin #" << c << ":";
+            for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++)
+                Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fRegionOfInterest;
+            Out() << endl;
+        }
+
+        for (unsigned int c=0; c<FAD::kNumChips; c++)
+        {
+            Out() << "StartCells #" << c << ":";
+            for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++)
+                Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell;
+            Out() << endl;
+        }
+
         if (fIsHexOutput)
             Out() << Converter::GetHex<uint16_t>(fChannelHeader, 16) << endl;
@@ -113,6 +144,4 @@
         }
 
-        // FIXME FIXME FIXME. The data block could have the same size!!!!!
-        // !!!!!!!!!!!!!!!!!!!
         if (type==kReadHeader)
         {
@@ -164,29 +193,30 @@
         }
 
-        /*
         uint8_t *ptr = reinterpret_cast<uint8_t*>(fBuffer.data());
+        uint8_t *end = ptr + fBuffer.size()*2;
         for (unsigned int i=0; i<FAD::kNumChannels; i++)
         {
-            if (ptr+sizeof(FAD::ChannelHeader)/2 > reinterpret_cast<uint8_t*>(fBuffer.data())+fBuffer.size()*2)
+            if (ptr+sizeof(FAD::ChannelHeader) > end)
             {
-                Error("WRONG SIZE1");
-                break;
+                Error("Channel header exceeds buffer size.");
+                PostClose(false);
+                return;
             }
 
-            // FIXME: Size consistency check!!!!
             fChannelHeader[i] = vector<uint16_t>((uint16_t*)ptr, (uint16_t*)ptr+sizeof(FAD::ChannelHeader)/2);
             ptr += sizeof(FAD::ChannelHeader);
 
-            // FIXME CHECK: Event Size vs ROI
-
-            UpdateChannelHeader(i);
-
-            if (ptr+fChannelHeader[i].fRegionOfInterest*2 > reinterpret_cast<uint8_t*>(fBuffer.data())+fBuffer.size()*2)
+            //UpdateChannelHeader(i);
+
+            if (ptr+fChannelHeader[i].fRegionOfInterest*2 > end)
             {
-                Error("WRONG SIZE2");
-                break;
+                Error("Data block exceeds buffer size.");
+                PostClose(false);
+                return;
             }
 
             uint16_t *data = reinterpret_cast<uint16_t*>(ptr);
+
+            /*
             for (uint16_t *d=data; d<data+fChannelHeader[i].fRegionOfInterest; d++)
             {
@@ -209,8 +239,11 @@
                 }
             }
+            */
 
             UpdateData(data, fChannelHeader[i].fRegionOfInterest*2);
             ptr += fChannelHeader[i].fRegionOfInterest*2;
-        }*/
+        }
+
+        UpdateChannelHeaders();
 
         fBuffer.resize(sizeof(FAD::EventHeader)/2);
@@ -310,5 +343,5 @@
     ConnectionFAD(ba::io_service& ioservice, MessageImp &imp) :
     Connection(ioservice, imp()),
-    fIsVerbose(true), fIsHexOutput(false), fIsDataOutput(false), fCounter(0)
+    fIsVerbose(false), fIsHexOutput(false), fIsDataOutput(false), fCounter(0)
     {
         // Maximum possible needed space:
