Commit 2d746ad5 authored by Sarah Seif El Nasr's avatar Sarah Seif El Nasr
Browse files

All FWInterfaces (CtaFWInterface.cc GlibFWInterface.cc ICFc7FWInterface.cc ...

All FWInterfaces (CtaFWInterface.cc  GlibFWInterface.cc  ICFc7FWInterface.cc  ICGlibFWInterface.cc) modified so that a CBC register write fails if the write operation is attempted more than MAX_WRITE_ATTEMPTS times.
parent 71b9f636
......@@ -29,6 +29,7 @@ namespace Ph2_HwInterface {
fpgaConfig = nullptr;
fData = nullptr;
fNthAcq = 0;
fRegWriteAttempts=0;
}
......@@ -39,7 +40,7 @@ namespace Ph2_HwInterface {
fpgaConfig ( nullptr ),
fData ( nullptr ),
fFileHandler ( pFileHandler ),
fNthAcq (0)
fNthAcq (0), fRegWriteAttempts(0)
{
if ( fFileHandler == nullptr ) fSaveToFile = false;
else fSaveToFile = true;
......@@ -51,7 +52,7 @@ namespace Ph2_HwInterface {
BeBoardFWInterface ( pId, pUri, pAddressTable ),
fpgaConfig ( nullptr ),
fData ( nullptr ),
fNthAcq (0)
fNthAcq (0), fRegWriteAttempts(0)
{
}
......@@ -64,7 +65,7 @@ namespace Ph2_HwInterface {
fpgaConfig ( nullptr ),
fData ( nullptr ),
fFileHandler ( pFileHandler ),
fNthAcq (0)
fNthAcq (0), fRegWriteAttempts(0)
{
if ( fFileHandler == nullptr ) fSaveToFile = false;
else fSaveToFile = true;
......@@ -737,18 +738,29 @@ namespace Ph2_HwInterface {
// now I need to make sure that the written and the read-back vector are the same
std::vector<uint32_t> cWriteAgain = get_mismatches (cWriteVec.begin(), cWriteVec.end(), pVecReq.begin(), CtaFWInterface::cmd_reply_comp);
// now check the size of the WriteAgain vector and assert Success or not
// also check that the number of write attempts does not exceed MAX_WRITE_ATTEMPTS
if (cWriteAgain.empty() ) cSuccess = true;
else
{
cSuccess = false;
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 120)
if (cWriteAgain.size() < 100 && fRegWriteAttempts < MAX_WRITE_ATTEMPTS )
{
LOG (INFO) << "There were " << cWriteAgain.size() << " Readback Errors while ckecking I2C writing - trying again!" ;
if (pReadback) LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " Readback Errors -trying again!" << RESET ;
else LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" << RESET ;
fRegWriteAttempts++;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else LOG(INFO) << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" ;
else if ( fRegWriteAttempts >= MAX_WRITE_ATTEMPTS )
{
cSuccess = false;
fRegWriteAttempts = 0 ;
}
//else std::cout << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" << std::endl;
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
}
......
......@@ -21,7 +21,8 @@
#include "../HWDescription/Module.h"
#include "../Utils/Visitor.h"
// maximum number of tries allowed to attempt a write procedure to a CBC register
const uint8_t MAX_WRITE_ATTEMPTS = 5 ;
using namespace Ph2_HwDescription;
......@@ -49,6 +50,8 @@ namespace Ph2_HwInterface {
FileHandler* fFileHandler ;
uint32_t fNthAcq, fNpackets;
bool fJustPaused;
// number of tries a CBC register write operation was attempted
uint8_t fRegWriteAttempts;
private:
/*!
......
......@@ -653,17 +653,22 @@ namespace Ph2_HwInterface {
// now I need to make sure that the written and the read-back vector are the same
std::vector<uint32_t> cWriteAgain = get_mismatches (cWriteVec.begin(), cWriteVec.end(), pVecReq.begin(), GlibFWInterface::cmd_reply_comp);
// now check the size of the WriteAgain vector and assert Success or not
// also check that the number of write attempts does not exceed MAX_WRITE_ATTEMPTS
if (cWriteAgain.empty() ) cSuccess = true;
else
{
cSuccess = false;
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 120 && fRegWriteAttempts < MAX_WRITE_ATTEMPTS )
if (cWriteAgain.size() < 100 && fRegWriteAttempts < MAX_WRITE_ATTEMPTS )
{
LOG (INFO) << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" ;
if (pReadback) LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " Readback Errors -trying again!" << RESET ;
else LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" << RESET ;
fRegWriteAttempts++;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
}
else if ( fRegWriteAttempts >= MAX_WRITE_ATTEMPTS )
{
cSuccess = false;
......
......@@ -26,7 +26,7 @@ namespace Ph2_HwInterface {
fData ( nullptr ),
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFMCId (1)
fFMCId (1) , fRegWriteAttempts(0)
{}
......@@ -39,7 +39,7 @@ namespace Ph2_HwInterface {
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFileHandler ( pFileHandler ),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{
if ( fFileHandler == nullptr ) fSaveToFile = false;
else fSaveToFile = true;
......@@ -53,7 +53,7 @@ namespace Ph2_HwInterface {
fData ( nullptr ),
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{}
......@@ -67,7 +67,7 @@ namespace Ph2_HwInterface {
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFileHandler ( pFileHandler ),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{
if ( fFileHandler == nullptr ) fSaveToFile = false;
else fSaveToFile = true;
......@@ -571,23 +571,30 @@ namespace Ph2_HwInterface {
}
// now check the size of the WriteAgain vector and assert Success or not
// also check that the number of write attempts does not exceed MAX_WRITE_ATTEMPTS
if (cWriteAgain.empty() ) cSuccess = true;
else
{
cSuccess = false;
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 100)
if (cWriteAgain.size() < 100 && fRegWriteAttempts < MAX_WRITE_ATTEMPTS )
{
if (pReadback) LOG (INFO) << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" ;
else LOG (INFO) << "There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" ;
if (pReadback) LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " Readback Errors -trying again!" << RESET ;
else LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" << RESET ;
fRegWriteAttempts++;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else LOG(INFO) << "There were too many errors (>100 Registers). Something is wrong - aborting!" ;
else if ( fRegWriteAttempts >= MAX_WRITE_ATTEMPTS )
{
cSuccess = false;
fRegWriteAttempts = 0 ;
}
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
return cSuccess;
}
......
......@@ -25,6 +25,9 @@
using namespace Ph2_HwDescription;
// maximum number of tries allowed to attempt a write procedure to a CBC register
const uint8_t MAX_WRITE_ATTEMPTS = 5 ;
/*!
* \namespace Ph2_HwInterface
* \brief Namespace regrouping all the interfaces to the hardware
......@@ -49,6 +52,10 @@ namespace Ph2_HwInterface {
uint32_t fNEventsperAcquistion;
uint32_t fDataSizeperEvent32;
uint32_t fFMCId;
// number of tries a CBC register write operation was attempted
uint8_t fRegWriteAttempts;
const uint32_t SINGLE_I2C_WAIT = 70; //usec for 1MHz I2C
// const uint32_t SINGLE_I2C_WAIT = 700; //usec for 100 kHz I2C
......
......@@ -26,7 +26,7 @@ namespace Ph2_HwInterface {
fData ( nullptr ),
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{}
......@@ -39,7 +39,7 @@ namespace Ph2_HwInterface {
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFileHandler ( pFileHandler ),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{
if ( fFileHandler == nullptr ) fSaveToFile = false;
else fSaveToFile = true;
......@@ -53,7 +53,7 @@ namespace Ph2_HwInterface {
fData ( nullptr ),
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{}
......@@ -67,7 +67,7 @@ namespace Ph2_HwInterface {
fBroadcastCbcId (0),
fReplyBufferSize (1024),
fFileHandler ( pFileHandler ),
fFMCId (1)
fFMCId (1), fRegWriteAttempts(0)
{
if ( fFileHandler == nullptr ) fSaveToFile = false;
else fSaveToFile = true;
......@@ -569,20 +569,27 @@ namespace Ph2_HwInterface {
}
// now check the size of the WriteAgain vector and assert Success or not
// also check that the number of write attempts does not exceed MAX_WRITE_ATTEMPTS
if (cWriteAgain.empty() ) cSuccess = true;
else
{
cSuccess = false;
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 100)
if (cWriteAgain.size() < 100 && fRegWriteAttempts < MAX_WRITE_ATTEMPTS )
{
if (pReadback) LOG (INFO) << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" ;
else LOG (INFO) << "There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" ;
if (pReadback) LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " Readback Errors -trying again!" << RESET ;
else LOG (INFO) << BOLDRED << "(WRITE#" << std::to_string(fRegWriteAttempts) << ") There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" << RESET ;
fRegWriteAttempts++;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else LOG(INFO) << "There were too many errors (>100 Registers). Something is wrong - aborting!" ;
else if ( fRegWriteAttempts >= MAX_WRITE_ATTEMPTS )
{
cSuccess = false;
fRegWriteAttempts = 0 ;
}
//else std::cout << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" << std::endl;
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
......
......@@ -25,6 +25,9 @@
using namespace Ph2_HwDescription;
// maximum number of tries allowed to attempt a write procedure to a CBC register
const uint8_t MAX_WRITE_ATTEMPTS = 5 ;
/*!
* \namespace Ph2_HwInterface
* \brief Namespace regrouping all the interfaces to the hardware
......@@ -50,6 +53,9 @@ namespace Ph2_HwInterface {
uint32_t fDataSizeperEvent32;
uint32_t fFMCId;
// number of tries a CBC register write operation was attempted
uint8_t fRegWriteAttempts;
const uint32_t SINGLE_I2C_WAIT = 70; //usec for 1MHz I2C
// const uint32_t SINGLE_I2C_WAIT = 700; //usec for 100 kHz I2C
static const int RESET_ALL = 0x1;
......
......@@ -324,13 +324,13 @@ void perform_AntennaOccupancyMeasurement(Tool pTool , std::string pHWFile )
{
LOG (INFO) << "Starting occupancy measurement using the antenna." ;
//AntennaTester cAntennaTester;
//cAntennaTester.Inherit (&pTool);
//cAntennaTester.ChangeHWDescription ( pHWFile );
//cAntennaTester.ChangeSettings ( pHWFile );
//cAntennaTester.ConfigureHw();
AntennaTester cAntennaTester;
cAntennaTester.Inherit (&pTool);
cAntennaTester.ChangeHWDescription ( pHWFile );
cAntennaTester.ChangeSettings ( pHWFile );
cAntennaTester.ConfigureHw();
//cAntennaTester.Initialize();
// re-configure CBC regsiters with values from the calibration
//cAntennaTester.ReconfigureCBCRegisters();
......@@ -338,7 +338,7 @@ void perform_AntennaOccupancyMeasurement(Tool pTool , std::string pHWFile )
//cAntennaTester.Measure();
// save results
//cAntennaTester.SaveResults();
// cAntennaTester.SaveResults();
//char line[120];
//sprintf(line, "# Top Pad Occupancy = %.2f ± %.3f" , cHybridTester.GetMeanOccupancyTop() , cHybridTester.GetRMSOccupancyTop() );
//cHybridTester.AmmendReport(line);
......
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