Commit 0e687bbf authored by Christoph Schwick's avatar Christoph Schwick
Browse files

references #126: add up to 3 retries for the caenvme_init call in case of failure.

parent b4d4f518
......@@ -54,7 +54,7 @@ HAL::CAENLinuxBusAdapter::CAENLinuxBusAdapter( CAENModel model, int unit, int ch
model_(model)
{
int status;
int status = 0;
int32_t handle;
// Initial check of parameters
......@@ -95,23 +95,34 @@ HAL::CAENLinuxBusAdapter::CAENLinuxBusAdapter( CAENModel model, int unit, int ch
if ( model == V2718 ) { // model V2718
// firmware version of the PCI board
if( (status=CAENVME_Init(pcCard_, unit_, 0, &handle)) != cvSuccess ) {
std::stringstream errorMessage;
errorMessage << "Could not initialize CAENVME library for PC card (status: "
<< status
<< ")"
<< std::ends;
sem_post(handleSemaphore_);
throw (BusAdapterException( errorMessage.str(), __FILE__, __LINE__, __FUNCTION__ ) );
}
if ( ( status = CAENVME_BoardFWRelease( handle, AX818FwRelease_ )) != cvSuccess ) {
std::stringstream errorMessage;
errorMessage << "Could not determine firmware version of " << pcCardStr_ << " (status: "
<< status
<< ")"
<< std::ends;
sem_post(handleSemaphore_);
throw (BusAdapterException( errorMessage.str(), __FILE__, __LINE__, __FUNCTION__ ) );
// we try three times since it has been found that in rare cases this call
// does not suceed at the first try (source : ECAL). Therefore this call
// might take substantial time (the timeout when it does not work is of the
// order of 10s of seconds according to ECAL)
uint32_t trials = 3;
while ( trials > 0 ) {
status=CAENVME_Init(pcCard_, unit_, 0, &handle);
if ( status == cvSuccess )
break;
trials--;
}
if( status != cvSuccess ) {
std::stringstream errorMessage;
errorMessage << "Could not initialize CAENVME library for PC card (status: "
<< status
<< ")"
<< std::ends;
sem_post(handleSemaphore_);
throw (BusAdapterException( errorMessage.str(), __FILE__, __LINE__, __FUNCTION__ ) );
}
if ( ( status = CAENVME_BoardFWRelease( handle, AX818FwRelease_ )) != cvSuccess ) {
std::stringstream errorMessage;
errorMessage << "Could not determine firmware version of " << pcCardStr_ << " (status: "
<< status
<< ")"
<< std::ends;
sem_post(handleSemaphore_);
throw (BusAdapterException( errorMessage.str(), __FILE__, __LINE__, __FUNCTION__ ) );
}
CAENVME_End( handle );
......@@ -144,7 +155,18 @@ HAL::CAENLinuxBusAdapter::CAENLinuxBusAdapter( CAENModel model, int unit, int ch
// firmware version of the VME Controller board (optical link version)
// This process must only call Init once!!!
if ( handleVX718UseCount_[unit_][chain_] == 0 ) {
if( (status=CAENVME_Init(cvV2718, unit_, chain_, &handleVX718_[unit_][chain_])) != cvSuccess ) {
// We try three times since it has been seen in ECAL that the Init call might fail
// in rare cases. The timeout for the init to fail is of the order ot 10s of seconds.
// Therefore this call might take a long time in case thre are problems during
// initialisation.
uint32_t trials = 3;
while ( trials > 0 ) {
status=CAENVME_Init(cvV2718, unit_, chain_, &handleVX718_[unit_][chain_]);
if (status == cvSuccess)
break;
trials--;
}
if( status != cvSuccess ) {
std::stringstream errorMessage;
errorMessage << "Could not initialize CAENVME library with cvV2718 (status: "
<< status
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment