Changeset 3907 in Sophya for trunk/AddOn


Ignore:
Timestamp:
Nov 5, 2010, 7:58:07 PM (15 years ago)
Author:
ansari
Message:

Ajout script verification donnees firmware FFT-shrink, Reza 05/11/2010

Location:
trunk/AddOn/TAcq
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/racqueth.cc

    r3904 r3907  
    5959      sok.SendAll(msg,BRTCPMSGLEN);
    6060      sok.ReceiveAll(msg,BRTCPMSGLEN);
    61       if (strncmp(msg,"BAORadio-EthernetReader-OK",26)!=0)
     61      if (strncmp(msg,"BAORadio-EthernetReader-OK",26)!=0) {
     62        msg[BRTCPMSGLEN-1]='\0';
     63        cout << "PCIEToEthernet:ERROR/ bad Init_Acknowledge message from EthernetReader : \n  " << msg << endl;
     64        usleep(10000);
    6265        throw SocketException("PCIEToEthernet:ERROR/  Connection to EthernetReader not established ");
     66      }
    6367      cout << " PCIEToEthernet: Ethernet connection established for DMA/fiber" << i << " with " << destname_[j] << endl;
    6468      vskt.push_back(sok);
     
    406410    for(int ii=0; ii<BRTCPMSGLEN; ii++) msg[ii]='\0';
    407411    sok.ReceiveAll(msg,BRTCPMSGLEN);
    408     if (strncmp(msg,"BAORadio-PCIEToEthernet",23)!=0)
     412    if (strncmp(msg,"BAORadio-PCIEToEthernet",23)!=0) {
     413      cout << " EthernetReader:ERROR, bad init message from PCIEToEthernet client -> throw SocketException" << endl;
    409414      throw SocketException("EthernetReader:ERROR/  Bad message from PCIEToEthernet client !");
     415    }
    410416    int ia,ib,ic,id,ie;
    411417    sscanf(msg+25,"%d %d %d %d %d",&ia,&ib,&ic,&id,&ie);
     
    414420      strcpy(msg,"BAORadio-EthernetReader-BAD MMgrNbPaquet/MMgrPaquetSize()");
    415421      sok.SendAll(msg,BRTCPMSGLEN);
     422      cout << " EthernetReader:ERROR, Bad client.MMgrNbPaquet/PaquetSize NbPaq=" << ia << " PaqSz=" << ib
     423           << " Reader_PaqSz=" << memgr_.PaqSize() << endl;
     424      usleep(10000);
    416425      throw SocketException("EthernetReader:ERROR/  Bad MMgrNbPaquet/MMgrPaquetSize() from PCIEToEthernet client !");
    417426    }
  • trunk/AddOn/TAcq/swrapsock.cc

    r3897 r3907  
    166166  : Socket()
    167167{
     168  Initialize(NULL, port, nconmax);
     169}
     170
     171/* --Methode-- */
     172ServerSocket::ServerSocket(const char* inadr, int port, int nconmax)
     173  : Socket()
     174{
     175  Initialize(inadr, port, nconmax);
     176}
     177
     178/* --Methode-- */
     179ServerSocket::ServerSocket(string const& inadr, int port, int nconmax)
     180  : Socket()
     181{
     182  Initialize(inadr.c_str(), port, nconmax);
     183}
     184
     185
     186/* --Methode-- */
     187void ServerSocket::Initialize(const char* str_inadr, int port, int nconmax)
     188{
    168189  int s,rc;
    169190  s = socket(AF_INET, SOCK_STREAM, 0);
    170191  if (s < 0) {
    171     cout << "ServerSocket() Pb socket() ErrNo=" <<  errno << endl; 
    172     throw SocketException("ServerSocket() Pb socket()");
     192    cout << "ServerSocket::Initialize()  Pb socketErrNo=" <<  errno << endl; 
     193    throw SocketException("ServerSocket::Initialize() Pb socket()");
    173194    }
    174195  skt = s;
     
    180201  ipskt.sin_family = AF_INET;
    181202  ipskt.sin_port = htons(port);
    182   ipskt.sin_addr.s_addr = INADDR_ANY;
     203  if (str_inadr==NULL) {   // pas d'adresse IP specifie
     204    ipskt.sin_addr.s_addr = INADDR_ANY;
     205  }
     206  else {  // adresse IP specifie sous la forme uuu.xxx.yyy.zzz.
     207    ipskt.sin_addr.s_addr = inet_addr(str_inadr);
     208  }
    183209  /* Je fais un cast explicit de sockaddr_in * (Internet) en sockaddr *   */
    184210  rc = bind(skt, (struct sockaddr *)(&ipskt), sizeof(ipskt));
    185211  if (rc < 0) {
    186212    Close();
    187     cout << "ServerSocket() Pb bind() ErrNo=" <<  errno << endl; 
    188     throw SocketException("ServerSocket() Pb bind()");
     213    cout << "ServerSocket::Initialize() Pb bind() ErrNo=" <<  errno << endl; 
     214    throw SocketException("ServerSocket::Initialize() Pb bind()");
    189215  }
    190216}
  • trunk/AddOn/TAcq/swrapsock.h

    r3901 r3907  
    8888public :
    8989  ServerSocket(int port, int nconmax);
     90  ServerSocket(const char* inadr, int port, int nconmax);
     91  ServerSocket(string const& inadr, int port, int nconmax);
    9092  Socket WaitClientConnection();
    9193  virtual int Close();  // redefinition de la methode de Socket::Close()
    9294
    9395protected:
     96  void Initialize(const char* inadr, int port, int nconmax);
     97
    9498  int portid;
    9599  struct sockaddr_in  ipskt;
  • trunk/AddOn/TAcq/tsok.cc

    r3639 r3907  
    1818
    1919void burawtst();
    20 int serverside();
     20int serverside(const char* adr=NULL);
    2121int clientside(string& servname, string& msg, string& args);
    2222
     
    3131  if (narg < 2) {
    3232    cout << " Erreur Argument / tsok.cc : Socket class tests \n"
    33          << "    Usage : tsok S/C [servername=localhost] [OPEMsg=Hello] [NLoop,SizeX,SizeY] [RIOS_NPaq=16]\n"
     33         << "    Usage : tsok S/s/C [servername=localhost] [OPEMsg=Hello] [NLoop,SizeX,SizeY] [RIOS_NPaq=16]\n"
    3434         << "    Ex: tsok S   or  tsok C serverName or \n"
    3535         << "        tsok C serverName PPFSOCKET  5,1000,800 \n"
    36          << "   S : run tsok as server side \n"
     36         << "   S/s : run tsok as server side, (S: specify ServerSocket In_Adress) \n"
    3737         << "   C : run tsok as client side \n"
    3838         << "   OPEMsg : Operation select on client side (=XXX , PPFSOCKET , STOP)   \n"
     
    4242  } 
    4343  bool fgserv = false;
    44   if (*arg[1] == 'S')  fgserv = true;
     44  bool fginadr = false;
     45  if (*arg[1] == 's')  fgserv = true;
     46  else if (*arg[1] == 'S') { fgserv=true;  fginadr=true; }
    4547  string servname = "localhost";
    4648  if (narg > 2)  servname = arg[2];
     
    5557    SophyaInit(); 
    5658    InitTim();
    57     if (fgserv) rc=serverside();
     59    if (fgserv) {
     60      if (fginadr) rc=serverside(servname.c_str());
     61      else rc=serverside();
     62    }
    5863    else if (*arg[1] == 'C') rc=clientside(servname, opemsg, oargs);
    5964    else burawtst();
     
    7681
    7782/* --Fonction-- */
    78 int serverside()
     83int serverside(const char* adr)
    7984{
    8085  int rc = 66;
    8186  cout << " ======== tsok.cc / ServerSide ============ " << endl;
    82   cout << " Creating server socket ... , PortId= " << PORTID << endl;
    83   ServerSocket srv(PORTID, 1);
     87  if (adr !=NULL)  cout << " Creating server socket InAddress=" << adr << ", PortId= " << PORTID << endl;
     88  else cout << " Creating server socket ... , PortId= " << PORTID << endl;
     89  ServerSocket srv(adr, PORTID, 1);
    8490  bool fgstop = false;
    8591  int nc = 0;
     
    144150    }  // fin while(! fgbye)
    145151    cout << "ServerSide: Closing current socket ..." << endl;
    146     skt.Close();
     152    skt.Close(); 
    147153    rc = 0;
    148154  }  // fin while(!fgstop)
Note: See TracChangeset for help on using the changeset viewer.