Changeset 10099


Ignore:
Timestamp:
01/11/11 14:44:34 (12 years ago)
Author:
ogrimm
Message:
Corrupt events (wrong start-package flag) are removed from internal buffer
Location:
fact/FADctrl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FAD.cc

    r10098 r10099  
    5757  MainThread = pthread_self();
    5858  Mode = idle;
    59   EventUpdateDelay = atof(GetConfig("EventUpdateDelay", "0.5").c_str())*1e6;
     59  EventUpdateDelay = atof(GetConfig("EventUpdateDelay", "0.5").c_str());
    6060
    6161  // DIM console service used in PrintMessage()
     
    7070  // Construct boards
    7171  BoardList = Tokenize(GetConfig("BoardList","129.217.160.119"));
    72 
     72  BoardList = Tokenize("192.33.99.225");
     73printf("%s ", BoardList[0].c_str());
    7374  for (unsigned int i=0; i<BoardList.size(); i++) {
    7475    Boards.push_back(new class FADBoard(BoardList[i], 5000, this, i));
     
    649650  vector<struct FADBoard::BoardStatus> Status;
    650651  vector<unsigned short> ROICmd;
    651   unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 2)), 0};
     652  unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
    652653
    653654  /* Procedure
     
    683684    // Set DAC first value
    684685    DACCmd[1] = htons(0);
     686    DACCmd[3] = htons(0);
     687    DACCmd[5] = htons(0);
    685688        Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    686689
     
    715718        // Set second DAC value
    716719    DACCmd[1] = htons(50000);
     720    DACCmd[3] = htons(50000);
     721    DACCmd[5] = htons(50000);
    717722        Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    718723
     
    754759        Boards[Brd]->Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
    755760 
    756     DACCmd[1] = htons(Status[Brd].DAC[2]);
     761    DACCmd[1] = htons(Status[Brd].DAC[1]);
     762    DACCmd[3] = htons(Status[Brd].DAC[2]);
     763    DACCmd[5] = htons(Status[Brd].DAC[3]);
    757764        Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    758765       
     
    842849  // Update loop
    843850  while (!ExitRequest) {
    844     usleep(EventUpdateDelay);
     851    usleep(EventUpdateDelay*1e6);
    845852
    846853        // Update run and event header with current time
  • fact/FADctrl/FADBoard.cc

    r10080 r10099  
    182182
    183183  static char Buffer[READ_BUFFER_SIZE];
    184   static unsigned int Pos = 0;
     184  static unsigned int Pos = 0, Temp;
    185185  const PEVNT_HEADER *Header = (PEVNT_HEADER *) Buffer;
    186186  ssize_t Result;
     
    218218        }
    219219       
    220         // Check if full event available in buffer
    221         if (Pos < sizeof(PEVNT_HEADER) || ntohs(Header->start_package_flag) != 0xfb01) continue;
     220        // Check if buffer starts with start_package_flag, remove data if not
     221        Temp = 0;
     222        while (ntohs(Header->start_package_flag) != 0xfb01 && Pos > 0) {
     223          memmove(Buffer, Buffer+1, Pos-1);
     224          Pos--;
     225          Temp++;
     226        }
     227        if (Temp != 0) {
     228          printf("Removed %d bytes because of start_package_flag not found\n", Temp);
     229          continue;
     230        }
     231
     232        // Wait until the buffer contains at least enough bytes to potentially hold a PEVNT_HEADER
     233        if (Pos < sizeof(PEVNT_HEADER)) continue;
    222234       
    223235        unsigned int Length = ntohs(Header->package_length)*2*sizeof(char);
  • fact/FADctrl/FADctrl.cc

    r10095 r10099  
    116116
    117117        //ETHZ
    118   //static char Hostname[] = "192.33.99.225";
     118  static char Hostname[] = "192.33.99.225";
    119119        //TUDO
    120         static char Hostname[] = "129.217.160.119";
     120        //static char Hostname[] = "129.217.160.119";
    121121  int List[] = {5001, 5002, 5003, 5004, 5005, 5006, 5007};
    122122  int Socket[sizeof(List)/sizeof(int)], MaxSocketNum=0, Ret;
Note: See TracChangeset for help on using the changeset viewer.