Index: trunk/AddOn/TAcq/brpaqu.cc
===================================================================
--- trunk/AddOn/TAcq/brpaqu.cc	(revision 3592)
+++ trunk/AddOn/TAcq/brpaqu.cc	(revision 3623)
@@ -55,4 +55,5 @@
   case BR_FFTOneChan :
   case BR_FFTTwoChan :
+    // Byte swap (sur 8 octets) de l'entete
     // ByteSwap 8 (4->8 Reza/firmware SGDMA) de l'enete 
     for(int ka=0; ka<BRHDRSIZE; ka+=8) {
@@ -63,4 +64,5 @@
     }
 
+    // on reoordonne les coeff FFT et on swappe en mem temps  (Byte-swap sur 8 octets)
     if (fgswap == BR_FFTOneChan) ReorderFFTData(src+HeaderSize(), dst_+HeaderSize(), DataSize());
     else if (fgswap == BR_FFTTwoChan) {
@@ -68,4 +70,5 @@
       ReorderFFTData(src+HeaderSize()+DataSize()/2, dst_+HeaderSize()+DataSize()/2, DataSize()/2);
     }
+    // Byte swap (sur 8 octets) du trailer 
     for(int ka=HeaderSize()+DataSize(); ka<sz_; ka+=8) {
       for(int kb=0; kb<4; kb++) {
@@ -78,6 +81,5 @@
   case BR_FFTOneChan32 :
   case BR_FFTTwoChan32 :
-    // on swappe tout  en attendant le swap general sinon il faut encore crÃ©er une fonctiondifferente de ReorderFFT
-    // swapp du header uniquement
+    // swap du header uniquement : Echange de deux mots de 4 octets
     for(int ka=0; ka<BRHDRSIZE/4; ka+=2) {
       dst32[ka] = src32[ka+1];
@@ -85,5 +87,5 @@
     }
   
-    // on reoordonne et on swappe en mem temps
+    // on reoordonne et on swappe en mem temps (Echange de deux mots de 4 octets)
     if (fgswap == BR_FFTOneChan32) ReorderFFTData32(src+HeaderSize(), dst_+HeaderSize(), DataSize());
     else if (fgswap == BR_FFTTwoChan32) {
@@ -91,5 +93,5 @@
       ReorderFFTData32(src+HeaderSize()+DataSize()/2, dst_+HeaderSize()+DataSize()/2, DataSize()/2);
     }
-    // swap du trailler uniquement
+    // swap du trailler uniquement : Echange de deux mots de 4 octets
     for(int ka=(HeaderSize()+DataSize())/4;ka < sz_/4; ka+=2) {
       dst32[ka] = src32[ka+1];
@@ -99,7 +101,11 @@
   case BR_FFTOneChanNoSwap :
   case BR_FFTTwoChanNoSwap :
-    // on a plus de swapdonc il faut copier dans dst
-    memcpy(dst_, src, sz_); 
-    // on reoordonne et on swappe en mem temps
+    // copie du header uniquement 
+    for(int ka=0; ka<BRHDRSIZE/4; ka++)  dst32[ka] = src32[ka];
+
+    //DEL  on a plus de swapdonc il faut copier dans dst
+    //DEL    memcpy(dst_, src, sz_); 
+
+    // on reoordonne les coeff FFT (pas de swap) 
     if (fgswap == BR_FFTOneChanNoSwap) ReorderFFTDataNoSwap(src+HeaderSize(), dst_+HeaderSize(), DataSize());
     else if (fgswap == BR_FFTTwoChanNoSwap) {
@@ -107,5 +113,7 @@
       ReorderFFTDataNoSwap(src+HeaderSize()+DataSize()/2, dst_+HeaderSize()+DataSize()/2, DataSize()/2);
     }
-    
+    // copie du trailler uniquement : 
+     for(int ka=(HeaderSize()+DataSize())/4;ka < sz_/4; ka++)  dst32[ka] = src32[ka];
+   
     break;
   }  // Fin switch 
@@ -143,22 +151,53 @@
 {
   UInt16 ModAq;
-  printf("Mod Acq %x \n",ModeAcq());
+//DEL  printf("Mod Acq %x \n",ModeAcq());
   ModAq = ((ModeAcq() & 0x30)>> 4);
   return(ModAq);
-  
-}
-
-/* --Methode__ */
-void BRPaquet::Print(ostream & os, int nelt, bool prht)
+}
+
+/* --Methode__ */
+void BRPaquet::SetHDRMarker64(UInt64 htag)
+{
+  *((UInt64*)(dst_+OFFSET)) = htag;
+  return;  	
+}
+
+/* --Methode__ */
+void BRPaquet::SetTRLMarker64(UInt64 ttag)
+{
+  *((UInt64*)(dst_+(sz_-BRTRLSIZE+OFFSET+1))) = 0;	
+  *((UInt64*)(dst_+(sz_-BRTRLSIZE+OFFSET))) = ttag; 
+  return;         	          	   	
+}
+
+/* --Methode__ */
+void BRPaquet::SetFrameCounter(UInt32 fc)
+{
+  UInt32* wp =  (UInt32*)(dst_+(BRFRCPTOFF+OFFSET));
+  *wp = (*wp & 0x0000FFFF) | ((fc<<16) & 0xFFFF0000); 
+  return;         	          	
+}
+
+/* --Methode__ */
+void BRPaquet::SetTimeTag(UInt64 timtag)
+{
+  UInt32* wp =  (UInt32*)(dst_+(BRFRCPTOFF+OFFSET));
+  UInt32 fc = *wp;
+  *((UInt64*)(dst_+(BRTMTAGOFF+OFFSET))) = timtag;
+  *wp = (*wp & 0x0000FFFF) | (fc & 0xFFFF0000);
+  return;         	
+}
+
+/* --Methode__ */
+ostream& BRPaquet::Print(ostream & os, int nelt, bool prht)
 {
   os << endl << "BRPaquet::Print() PaqSz=" << PaquetSize() << " DataSize=" << DataSize() 
-     << " dst_pointer=(hex)" << hex << (unsigned long)dst_ << dec << endl;
+     << " dst_pointer=(hex)" << hex << (unsigned long)dst_ << dec << endl; 
   if (dst_ == NULL) {
     os << " ...NULL paquet " << endl;
-    return; 
+    return os; 
   }
-
-  os << endl << " BR AcqMode: " << ModeAcquisition() << " Channel: " << ChannelID()  << endl;
-
+  os << " BR AcqMode: " << ModeAcquisition() << " Channel: " << ChannelID()  
+     << " FrameCounter=" << FrameCounter() << " FrameDataLen=" << PaqLen() << endl;
   if (TrailerSize() > 0) 
     os << " ...HDRMarker(hex)=" << hex <<  HDRMarker() << " TRLMarker=" << TRLMarker() << dec << endl;
@@ -168,5 +207,6 @@
   tt2 = TimeTag1(); 
   tt1 = TimeTag2();
-  os << " ...TimeTag (hex)=" << hex << "TimeTag()" << " TT1= " << tt1 << " TT2=" << tt2 << dec << endl;
+  os << " ...TimeTag (hex)=" << hex << " TT1= " << tt1 << " TT2=" << tt2 
+     << dec << " ->TimeTag()=" << TimeTag() << endl;
   // os << " ...Position Chariot (hex)= " << hex << PositionChariot() << endl;
   if (nelt > DataSize()/2) nelt = DataSize()/2;
@@ -192,4 +232,5 @@
     }
   }
+  return os;
 }
 
@@ -401,4 +442,6 @@
   lostframes = 0;
   frclst = 0;
+  DefineHDRTag();
+  DefineTRLTag();
 }
 
@@ -407,8 +450,30 @@
 }
 
+UInt64 BRPaqChecker::DefineHDRTag(UInt32 hdr1, UInt32 hdr2)
+{
+  hdrtag_ = (UInt64)hdr1 + ((UInt64)hdr2 << 32);
+  return hdrtag_;
+}
+
+UInt64 BRPaqChecker::DefineTRLTag(UInt32 trl1, UInt32 trl2)
+{
+  trltag_ = (UInt64)trl1 + ((UInt64)trl2 << 32);
+  return trltag_;
+}
+
+
+static int cnt_pb = 0;
 bool BRPaqChecker::Check(BRPaquet& paq)
 {
   totnframes++; 
-  if (paq.HDRMarker() != 0x76543210) return false;
+  if (paq.HDRMarker64() != HDRTag()) return false;
+  if (paq.TRLMarker64() != TRLTag()) return false;
+  /*
+  if (paq.TRLMarker64() != TRLTag()) { 
+    cnt_pb++; 
+    if (cnt_pb < 5) paq.Print();
+    return false;
+  }
+  */
   unsigned int curfc = paq.FrameCounter();
   unsigned int delfc = 0;
@@ -419,4 +484,5 @@
   }
   nframeok++; frclst = curfc; 
+  if (cnt_pb<5) { cnt_pb++; paq.Print(); }
   return true;
 }
@@ -424,5 +490,7 @@
 ostream& BRPaqChecker::Print(ostream& os)
 {
-  os << "BRPaqChecker:  Tot.Nb.Frames.Proc=" << totnframes << " NbFrameOK=" << nframeok 
+  //  os << "BRPaqChecker:  HDRTag=" << hex << HDRTag() << " TRLTag=" << TRLTag() << dec << "\n"
+  //     << " ... Tot.Nb.Frames.Proc=" << totnframes << " NbFrame HDR/TRL OK=" << nframeok 
+  os << "BRPaqChecker: Tot.Nb.Frames.Proc=" << totnframes << " NbFrame HDR/TRL OK=" << nframeok 
      << " LostFrames=" << lostframes 
      << " Loss=" << (double)lostframes*100./(double)totnframes << " %" << endl;
