Changeset 10291 for fact/FADctrl


Ignore:
Timestamp:
04/06/11 12:19:38 (14 years ago)
Author:
ogrimm
Message:
Bug fix to internal pipe communication
Location:
fact/FADctrl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FAD.cc

    r10290 r10291  
    753753void FAD::cmd_stop() {
    754754
    755   static char Stop[] = "stop";
     755  static char Stop[] = "stop\n";
    756756
    757757  if (Mode == idle) {
     
    767767  if (Mode == datarun) { 
    768768        // Inform event thread to stop run in case datarun active
    769         if (write(Pipe[1], Stop, strlen(Stop)+1) == -1) {
     769        if (write(Pipe[1], Stop, strlen(Stop)) == -1) {
    770770          Message(ERROR, "write() to Pipe[1] failed in FAD::cmd_cancel() (%s)", strerror(errno));
    771771        }
     
    896896  // Update loop
    897897  while (!ExitRequest) {
     898        // Removed processed data from IDString
     899        size_t LastLF = IDString.find_last_of("\n");
     900        if (LastLF != string::npos) IDString = IDString.substr(LastLF+1);
     901
    898902    // Wait for data from TCP/IP reading threads
    899903    if ((Ret=read(Pipe[0], Buffer, sizeof(Buffer))) == -1) Message(FATAL, "read() from Pipe[0] failed in FAD::EventThread() (%s)", strerror(errno));
     
    901905        // Check if pipe closed
    902906        if (Ret == 0) break;
    903        
    904         IDString = string(Buffer, Ret);
     907
     908        IDString.append(string(Buffer, Ret));
    905909
    906910        // If amplitude calibration mode, check if board finished procedure
     
    939943
    940944          if (lseek(Datafile, 0, SEEK_SET) == -1) {
    941             PrintMessage("Error: Could not rewind file to write updated run header (%s)\n", strerror(errno));
     945            Message(ERROR, "Could not rewind file to write updated run header (%s)", strerror(errno));
    942946          }
    943947          else if (write(Datafile, RHeader, sizeof(RunHeader)) != sizeof(RunHeader)) {
    944                 PrintMessage("Error: Could not write updated run header (%s)\n", strerror(errno));
     948                Message(ERROR, "Could not write updated run header (%s)", strerror(errno));
    945949          }
    946950
    947951          // Close data file and terminate run
    948           if(close(Datafile) == -1) PrintMessage("Error: Could not close data file (%s)\n", strerror(errno));
     952          if(close(Datafile) == -1) Message(ERROR, "Could not close data file (%s)", strerror(errno));
    949953          else PrintMessage("Data file closed (size %.1f MByte).\n", FileSize/1024.0/1024);
    950954
  • fact/FADctrl/FADBoard.cc

    r10290 r10291  
    8484  }
    8585
     86  // Delete condition variable
     87  if ((Ret = pthread_cond_destroy(&CondVar)) != 0) {
     88        m->Message(m->ERROR, "pthread_cond_destroy() failed for %s in ~FADBoard (%s)", Name, strerror(Ret));
     89  }
     90
     91  // Delete mutex 
     92  if ((Ret = pthread_mutex_destroy(&Mutex)) != 0) {
     93        m->Message(m->ERROR, "pthread_mutex_destroy() failed for %s in ~FADBoard (%s)", Name, strerror(Ret));
     94  }
     95
    8696  delete DIM_Name;
    8797  delete DIM_Status;
     
    93103  delete DIM_ROI; 
    94104  delete[] Name;
    95 
    96   // Delete condition variable
    97   if ((Ret = pthread_cond_destroy(&CondVar)) != 0) {
    98         m->Message(m->ERROR, "pthread_cond_destroy() failed in ~FADBoard (%s)", strerror(Ret));
    99   }
    100 
    101   // Delete mutex 
    102   if ((Ret = pthread_mutex_destroy(&Mutex)) != 0) {
    103         m->Message(m->ERROR, "pthread_mutex_destroy() failed in ~FADBoard (%s)", strerror(Ret));
    104   }
    105105}
    106106
     
    162162  vector<unsigned short> ROICmd;
    163163  unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
    164   string Message = string("ACALIBDONE")+Name;
     164  string Message = string("ACALIBDONE")+Name+"\n";
    165165
    166166  switch (State) {
     
    540540         
    541541          // Inform event thread of new data
    542           string Message = string("EVENT")+Name;
     542          string Message = string("EVENT")+Name+"\n";
    543543          if (write(m->Pipe[1], Message.data(), Message.size()) == -1) {
    544544                m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard (%s)", strerror(errno));
    545                 m->ExitRequest = true;
    546           }         
     545                break;
     546          }
    547547        }
    548548        else SetStatus("End package flag incorrect, removing corrupt event");
  • fact/FADctrl/History.txt

    r10290 r10291  
    2121                        Limited update rate of slow control data to 1 second or interval set by 'update'
    22221/4/2011        Added DIM frequency service
    23 5/4/2011        Added DIM rate service for each board           
     235/4/2011        Added DIM rate service for each board
     246/4/2011        Bug fix in internal pipe communication 
Note: See TracChangeset for help on using the changeset viewer.