Index: /trunk/AddOn/TAcq/brparam.cc
===================================================================
--- /trunk/AddOn/TAcq/brparam.cc	(revision 3900)
+++ /trunk/AddOn/TAcq/brparam.cc	(revision 3901)
@@ -137,6 +137,6 @@
   ethr_nlink=0;
   ethr_forcesamefc_=false;
-  ethr_sfc_maxdpc_=50;
-  ethr_sfc_maxresync_=50;
+  ethr_sfc_maxdpc_=0;
+  ethr_sfc_maxresync_=0;
   ethr_waitendmsg_=false;
 
@@ -262,6 +262,6 @@
   if (conf.HasKey("ethrforcesamefc"))  {
     ethr_forcesamefc_=true;   // force SAME FrameCounter   on all links
-    ethr_sfc_maxdpc_=conf.IParam("ethrforcesamefc",0,50);
-    ethr_sfc_maxresync_=conf.IParam("ethrforcesamefc",1,50);
+    ethr_sfc_maxdpc_=conf.IParam("ethrforcesamefc",0,0);
+    ethr_sfc_maxresync_=conf.IParam("ethrforcesamefc",1,0);
   }
   if (conf.HasKey("ethrwaitendmsg"))  ethr_waitendmsg_=true;
Index: /trunk/AddOn/TAcq/racqueth.cc
===================================================================
--- /trunk/AddOn/TAcq/racqueth.cc	(revision 3900)
+++ /trunk/AddOn/TAcq/racqueth.cc	(revision 3901)
@@ -466,5 +466,10 @@
     bool fgok=true;
     while (fgok&&(totnpaqrd_<par_.MaxNbPaquets())) {
-      if (stop_) break;
+      if (stop_) { 
+        if (prtlev_>0)  
+	  cout << ">S>S>S> EthernetReader::run() / Stopping, through Stop() method" << endl;  
+        stopreason_="EthernetReader::run() / Stopping, through Stop() method";
+        break;
+      }
       if ( MoveToNextTarget() ) {
 	cout << "EthernetReader::run()/Error-A- MoveToNextTarget() returned true ->STOP 9" << endl;
@@ -485,4 +490,9 @@
 	       << totsamefc_ << " / NPaqFib0Read=" << totnpqrd_[0] 
 	       << " FracSameFC=" << 100*totsamefc_/totnpqrd_[0] << " %" <<  endl;
+      }
+      if (totnpaqrd_>=par_.MaxNbPaquets()) { 
+        if (prtlev_>0)  
+	  cout << ">S>S>S> EthernetReader::run() / Stopping, totnpaqrd_>=par_.MaxNbPaquets()" << endl;  
+        stopreason_="EthernetReader::run() / Stopping, totnpaqrd_>=par_.MaxNbPaquets()";
       }
     }
@@ -537,6 +547,148 @@
 bool EthernetReader::ReadNextAllFibers()
 {
-  if (SkipAndSyncLinks()>8)  return true;
- 
+  if (sfc_maxresync_>0) return ReadNextAllFibersWithSync();
+
+  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
+    if (ReadNext(fib)) return true;  // probleme 
+  }
+  if (!rdsamefc_ || (memgr_.NbFibres()<2))  {
+    uint_8 cfc=curfc_[0];
+    bool fgsamefc=true;
+    for(size_t fib=1; fib<memgr_.NbFibres(); fib++) {
+      if (curfc_[fib]!=cfc)   fgsamefc=false;
+    }
+    if (fgsamefc)  totsamefc_++;  
+    return false;  // c'est OK 
+  }
+  //  On va essayer de lire jusqu'a avoir same_frame_counter 
+  uint_8 cfc=curfc_[0];
+  bool fgsamefc=true;
+  for(size_t fib=1; fib<memgr_.NbFibres(); fib++) {
+    if (curfc_[fib]!=cfc) {
+      fgsamefc=false;
+      if (curfc_[fib] > cfc)  cfc=curfc_[fib]; 
+    }
+  }
+  if (fgsamefc) { 
+    totsamefc_++;  return false;  // c'est OK  , same framecounter
+  }
+  else {  // else !fgsame
+    bool encorerd=true;
+    uint_4  ntrd=0;
+    while(encorerd) {
+      encorerd=false;
+      for(uint_4 fib=0; fib<memgr_.NbFibres(); fib++) {
+        if (curfc_[fib]>=cfc)  continue;
+	if (ReadNext(fib)) return true;  // probleme 	  
+	encorerd=true;         
+      }
+      ntrd++;
+      if (ntrd>sfc_maxdpc_) {
+        if (prtlev_>0)  
+	  cout << ">S>S>S> EthernetReader::ReadNextAllFibers(" << fib << ")/ Stopping, Nb_ReadNext="  
+               << ntrd << " > sfc_maxdpc_" << endl; 
+        stopreason_="ReadNextAllFibers() StopReason: failed to get SameFC Nb_ReadNext>sfc_maxdpc_";
+        return true; 
+      }
+    }
+  }   // fin de  else !fgsame 
+
+  return true; // probleme 
+}
+
+/* --Methode-- */
+bool EthernetReader::ReadNext(int fib)
+{
+  bool fggood=false;
+  while(!fggood) { 
+    ReceiveFromSocket(fib, (char *)vpaq_[fib].Begin(), packsize_);
+    if (vec_fgsokend_[fib])   {   // fin de reception sur le lien 
+      if (prtlev_>0)  
+	cout << ">S>S>S> EthernetReader::ReadNext(" << fib << ")/ Stopping, reason EndReceive fgsokend_=" 
+	     << vec_fgsokend_[fib] << endl; 
+      stopreason_="ReadNext() StopReason: EndReceive signaled on link";
+      return true; 
+    }
+    totnbytesrd_+=packsize_;
+    totnpqrd_[fib]++;
+    fggood = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
+  }
+  totnpqok_[fib]++;
+  return false;
+}
+
+/* --Methode-- */
+void EthernetReader::CleanUpAllSockets()
+{
+  bool fgallfinished=false;
+  while (!fgallfinished) {
+    fgallfinished=true;
+    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
+      if (vec_fgsokend_[fib]>0) continue;
+      ReceiveFromSocket(fib,dummybuff_,packsize_);
+      fgallfinished=false;
+    }
+  }
+  return;
+}
+
+/* --Methode-- */
+size_t EthernetReader::ReceiveFromSocket(int fib, char* data, size_t len)
+{
+  size_t rc =0;
+  if (vec_fgsokend_[fib]) { // la lecture est finie 
+    memset(data, 0, len);
+    return 0;
+  }
+
+  if (vec_cntpaq_[fib]%memgr_.NbPaquets() == 0) { 
+    char msg[BRTCPMSGLEN2];
+    msg[0]='\0';
+    vsok_[fib].ReceiveAll(msg, BRTCPMSGLEN2);
+    //    if (strncmp(msg,"PCIEToEthernet-SendCnt",22) != 0) 
+    //      cout << " EthernetReader::ReceiveFromSocket/ BAD HandShake message : " << msg << endl;
+    bool fgbadhsm=true;
+    if (strncmp(msg,"PCIEToEthernet-Send",19)==0) {
+      if (strncmp(msg+19,"Cnt",3)==0) fgbadhsm=false;
+      else if (strncmp(msg+19,"-END",4)==0) {
+	fgbadhsm=false;
+	vec_fgsokend_[fib]=1;  gl_fgsokend=true;
+	//DBG	cout << "ReceiveFromSocket/DEBUG -END msg received  " << endl;
+	if (prtlev_>2)  
+	  cout << " EthernetReader::ReceiveFromSocket/ Receive on LinkNo" << fib << " Ended OK" << endl;
+      }
+    }
+    if (fgbadhsm) {
+      cout << " EthernetReader::ReceiveFromSocket/ BAD HandShake, LinkNo " <<  fib << " msg: " << msg << endl;
+      vec_fgsokend_[fib]=2; 
+    }
+  }
+
+  if (vec_fgsokend_[fib]>0) { // la lecture est finie 
+    memset(data, 0, len);
+    return 0;
+  }
+
+  rc += vsok_[fib].ReceiveAll(data, len);
+  vec_cntpaq_[fib]++;
+
+#ifdef BR_DO_HANDSHAKE
+  // Envoi de message de hand-shake 
+  if (vec_cntpaq_[fib]%memgr_.NbPaquets() == 0) {
+    char msg[BRTCPMSGLEN2];
+    sprintf(msg,"EthernetReader-RecvCnt %d",vec_cntpaq_[fib]);
+    vsok_[fib].SendAll(msg, BRTCPMSGLEN2);
+    //DBG    cout << " ReceiveFromSocket/DEBUG-B msg=" << msg << endl;
+  }
+#endif  
+  return rc;
+}
+
+/* --Methode-- */
+bool EthernetReader::ReadNextAllFibersWithSync()
+{
+  if (rdsamefc_&&(sfc_maxresync_>0)) {
+    if (SkipAndSyncLinks()>8)  return true;
+  }
   for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
     if (ReadNext(fib)) return true;  // probleme 
@@ -557,7 +709,7 @@
     if (nbechec>sfc_maxresync_)  { 
       if (prtlev_>0)  
-	cout << ">S>S>S> EthernetReader::ReadNextAllFibers()/ Stopping, reason NbEchec>(NbMax_Resync=" 
+	cout << ">S>S>S> EthernetReader::ReadNextAllFibersWithSync()/ Stopping, reason NbEchec>(NbMax_Resync=" 
 	     << sfc_maxresync_ << ")" << endl; 
-      stopreason_="ReadNextAllFibers() , StopReason: NbEchec>NbMax_Resyn";
+      stopreason_="ReadNextAllFibersWithSync() , StopReason: NbEchec>NbMax_Resyn";
       return true;
     }
@@ -574,5 +726,4 @@
     }
     else {  // else !fgsame
-      if (nbechec>sfc_maxresync_)  return true;
       if (nbechec>0)   {
 	int rcres=SkipAndSyncLinks();
@@ -596,5 +747,5 @@
       
       if (prtlev_>5) 
-	cout << " EthernetReader::ReadNextAllFibers()/DEBUG NbEchec=" << nbechec  
+	cout << " EthernetReader::ReadNextAllFibersWithSync()/DEBUG NbEchec=" << nbechec  
 	     << " cfc=" << cfc << endl;
       
@@ -605,4 +756,5 @@
 	}
       }
+
       nbechec++;
     }   // fin de  else !fgsame 
@@ -610,92 +762,4 @@
 
   return true; // probleme 
-}
-
-/* --Methode-- */
-bool EthernetReader::ReadNext(int fib)
-{
-  bool fggood=false;
-  while(!fggood) { 
-    ReceiveFromSocket(fib, (char *)vpaq_[fib].Begin(), packsize_);
-    if (vec_fgsokend_[fib])   {   // fin de reception sur le lien 
-      if (prtlev_>0)  
-	cout << ">S>S>S> EthernetReader::ReadNext(" << fib << ")/ Stopping, reason EndReceive fgsokend_=" 
-	     << vec_fgsokend_[fib] << endl; 
-      stopreason_="ReadNext() StopReason: EndReceive signaled on link";
-      return true; 
-    }
-    totnbytesrd_+=packsize_;
-    totnpqrd_[fib]++;
-    fggood = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
-  }
-  totnpqok_[fib]++;
-  return false;
-}
-
-/* --Methode-- */
-void EthernetReader::CleanUpAllSockets()
-{
-  bool fgallfinished=false;
-  while (!fgallfinished) {
-    fgallfinished=true;
-    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
-      if (vec_fgsokend_[fib]>0) continue;
-      ReceiveFromSocket(fib,dummybuff_,packsize_);
-      fgallfinished=false;
-    }
-  }
-  return;
-}
-
-/* --Methode-- */
-size_t EthernetReader::ReceiveFromSocket(int fib, char* data, size_t len)
-{
-  size_t rc =0;
-  if (vec_fgsokend_[fib]) { // la lecture est finie 
-    memset(data, 0, len);
-    return 0;
-  }
-
-  if (vec_cntpaq_[fib]%memgr_.NbPaquets() == 0) { 
-    char msg[BRTCPMSGLEN2];
-    msg[0]='\0';
-    vsok_[fib].ReceiveAll(msg, BRTCPMSGLEN2);
-    //    if (strncmp(msg,"PCIEToEthernet-SendCnt",22) != 0) 
-    //      cout << " EthernetReader::ReceiveFromSocket/ BAD HandShake message : " << msg << endl;
-    bool fgbadhsm=true;
-    if (strncmp(msg,"PCIEToEthernet-Send",19)==0) {
-      if (strncmp(msg+19,"Cnt",3)==0) fgbadhsm=false;
-      else if (strncmp(msg+19,"-END",4)==0) {
-	fgbadhsm=false;
-	vec_fgsokend_[fib]=1;  gl_fgsokend=true;
-	//DBG	cout << "ReceiveFromSocket/DEBUG -END msg received  " << endl;
-	if (prtlev_>2)  
-	  cout << " EthernetReader::ReceiveFromSocket/ Receive on LinkNo" << fib << " Ended OK" << endl;
-      }
-    }
-    if (fgbadhsm) {
-      cout << " EthernetReader::ReceiveFromSocket/ BAD HandShake, LinkNo " <<  fib << " msg: " << msg << endl;
-      vec_fgsokend_[fib]=2; 
-    }
-  }
-
-  if (vec_fgsokend_[fib]>0) { // la lecture est finie 
-    memset(data, 0, len);
-    return 0;
-  }
-
-  rc += vsok_[fib].ReceiveAll(data, len);
-  vec_cntpaq_[fib]++;
-
-#ifdef BR_DO_HANDSHAKE
-  // Envoi de message de hand-shake 
-  if (vec_cntpaq_[fib]%memgr_.NbPaquets() == 0) {
-    char msg[BRTCPMSGLEN2];
-    sprintf(msg,"EthernetReader-RecvCnt %d",vec_cntpaq_[fib]);
-    vsok_[fib].SendAll(msg, BRTCPMSGLEN2);
-    //DBG    cout << " ReceiveFromSocket/DEBUG-B msg=" << msg << endl;
-  }
-#endif  
-  return rc;
 }
 
Index: /trunk/AddOn/TAcq/racqueth.h
===================================================================
--- /trunk/AddOn/TAcq/racqueth.h	(revision 3900)
+++ /trunk/AddOn/TAcq/racqueth.h	(revision 3901)
@@ -96,5 +96,5 @@
   // Si force_samefc=true, on essaye de lire des paquets avec meme FrameCounter, sans depasser une 
   // difference maximum de maxdiff_paqnum entre nombre de paquets lus sur chaque fibre
-  inline void SetReadMode(bool force_samefc=false, uint_4 maxdiff_paqnum=50, uint_4 maxresync=50)
+  inline void SetReadMode(bool force_samefc=false, uint_4 maxdiff_paqnum=0, uint_4 maxresync=0)
   { rdsamefc_=force_samefc; sfc_maxdpc_=maxdiff_paqnum; sfc_maxresync_=maxresync; }
   //  En activant le flag, le reader ne se termine qu'avec la reception des message END sur chaque lien 
@@ -115,4 +115,5 @@
   size_t ReceiveFromSocket(int fib, char* data, size_t len);
 
+  bool ReadNextAllFibersWithSync();      // Renvoie true si probleme 
 // recale les links en cas d'ecart important entre nb de paquets lu sur chaque lien
   int SkipAndSyncLinks();   // Renvoie 0 si rien fait, 1 si skip fait, 9 si probleme  
Index: /trunk/AddOn/TAcq/swrapsock.h
===================================================================
--- /trunk/AddOn/TAcq/swrapsock.h	(revision 3900)
+++ /trunk/AddOn/TAcq/swrapsock.h	(revision 3901)
@@ -44,4 +44,10 @@
   size_t ReceiveAll(char * buff, size_t len);
 
+/* Configuration nombre maxi de retry et temps d'attente (microsecondes) 
+   pour SendAll et ReceiveAll 
+  inline void SetSendRecvAllMaxNTry(int maxnt=20, int slus=100)
+  {  maxntry_=maxnt; slus_retry_=slus; }
+*/
+
   virtual int Close();
   
@@ -69,4 +75,5 @@
   long lstnbb;    /*  Nb bytes last send or receive */
   long errcnt;    /*  Total error count */
+//  int maxntry_;  int slus_retry_;
   int prtlev;
 };
