Commit 318125ac authored by Georg Auzinger's avatar Georg Auzinger
Browse files

added easylogging to HWInterface classes

parent 0d89568b
......@@ -60,29 +60,29 @@ namespace Ph2_HwInterface {
//void BeBoardFWInterface::getBoardInfo()
//{
//std::cout << "FMC1 present : " << ReadReg( "status.fmc1_present" ) << std::endl;
//std::cout << "FMC2 present : " << ReadReg( "status.fmc2_present" ) << std::endl;
//std::cout << "FW version : " << ReadReg( "firm_id.firmware_major" ) << "." << ReadReg( "firm_id.firmware_minor" ) << "." << ReadReg( "firm_id.firmware_build" ) << std::endl;
//LOG(INFO) << "FMC1 present : " << ReadReg( "status.fmc1_present" ) ;
//LOG(INFO) << "FMC2 present : " << ReadReg( "status.fmc2_present" ) ;
//LOG(INFO) << "FW version : " << ReadReg( "firm_id.firmware_major" ) << "." << ReadReg( "firm_id.firmware_minor" ) << "." << ReadReg( "firm_id.firmware_build" ) ;
//uhal::ValWord<uint32_t> cBoardType = ReadReg( "board_id" );
//std::cout << "BoardType : ";
//LOG(INFO) << "BoardType : ";
//char cChar = ( ( cBoardType & cMask4 ) >> 24 );
//std::cout << cChar;
//LOG(INFO) << cChar;
//cChar = ( ( cBoardType & cMask3 ) >> 16 );
//std::cout << cChar;
//LOG(INFO) << cChar;
//cChar = ( ( cBoardType & cMask2 ) >> 8 );
//std::cout << cChar;
//LOG(INFO) << cChar;
//cChar = ( cBoardType & cMask1 );
//std::cout << cChar << std::endl;
//LOG(INFO) << cChar ;
//std::cout << "FMC User Board ID : " << ReadReg( "user_wb_ttc_fmc_regs.user_board_id" ) << std::endl;
//std::cout << "FMC User System ID : " << ReadReg( "user_wb_ttc_fmc_regs.user_sys_id" ) << std::endl;
//std::cout << "FMC User Version : " << ReadReg( "user_wb_ttc_fmc_regs.user_version" ) << std::endl;
//LOG(INFO) << "FMC User Board ID : " << ReadReg( "user_wb_ttc_fmc_regs.user_board_id" ) ;
//LOG(INFO) << "FMC User System ID : " << ReadReg( "user_wb_ttc_fmc_regs.user_sys_id" ) ;
//LOG(INFO) << "FMC User Version : " << ReadReg( "user_wb_ttc_fmc_regs.user_version" ) ;
//}
......@@ -99,11 +99,11 @@ namespace Ph2_HwInterface {
//}
//catch ( std::exception& e )
//{
//std::cerr << "Death to Stop in BeBoardFWInterface::StopThread()" << e.what() << std::endl;
//std::cerr << "Death to Stop in BeBoardFWInterface::StopThread()" << e.what() ;
//}
//catch ( ... )
//{
//std::cerr << "Death to Stop in BeBoardFWInterface::StopThread(). failed to perform thrAcq.join()" << std::endl;
//std::cerr << "Death to Stop in BeBoardFWInterface::StopThread(). failed to perform thrAcq.join()" ;
//}
//}
......
......@@ -20,6 +20,7 @@
#include "../Utils/Utilities.h"
#include "../Utils/Exception.h"
#include "../Utils/FileHandler.h"
#include "../Utils/easylogging++.h"
#include "../HWDescription/BeBoard.h"
#include "../HWDescription/Definition.h"
#include "../HWDescription/CbcRegItem.h"
......
......@@ -35,7 +35,7 @@ namespace Ph2_HwInterface {
BeBoardFWMap::iterator i = fBoardMap.find ( pBoardIdentifier );
if ( i == fBoardMap.end() )
std::cout << "The Board: " << + ( pBoardIdentifier >> 8 ) << " doesn't exist" << std::endl;
LOG (INFO) << "The Board: " << + ( pBoardIdentifier >> 8 ) << " doesn't exist" ;
else
{
fBoardFW = i->second;
......@@ -99,7 +99,7 @@ namespace Ph2_HwInterface {
}
catch (...)
{
std::cerr << "Error while reading: " + cReg.first << std::endl;
std::cerr << "Error while reading: " + cReg.first ;
throw ;
}
}
......
......@@ -25,7 +25,7 @@ namespace Ph2_HwInterface {
fTransactionCount ( 0 )
{
#ifdef COUNT_FLAG
std::cout << "Counting number of Transactions!" << std::endl;
LOG (DEBUG) << "Counting number of Transactions!" ;
#endif
}
......@@ -36,7 +36,7 @@ namespace Ph2_HwInterface {
void CbcInterface::output()
{
#ifdef COUNT_FLAG
std::cout << "This instance of HWInterface::CbcInterface wrote (only write!) " << fRegisterCount << " Registers in " << fTransactionCount << " Transactions (only write!)! " << std::endl;
LOG (DEBUG) << "This instance of HWInterface::CbcInterface wrote (only write!) " << fRegisterCount << " Registers in " << fTransactionCount << " Transactions (only write!)! " ;
#endif
}
......@@ -47,7 +47,7 @@ namespace Ph2_HwInterface {
BeBoardFWMap::iterator i = fBoardMap.find ( pBoardIdentifier );
if ( i == fBoardMap.end() )
std::cout << "The Board: " << + ( pBoardIdentifier >> 8 ) << " doesn't exist" << std::endl;
LOG (INFO) << "The Board: " << + ( pBoardIdentifier >> 8 ) << " doesn't exist" ;
else
{
fBoardFW = i->second;
......@@ -140,7 +140,7 @@ namespace Ph2_HwInterface {
if (!cFailed)
pCbc->setReg ( cName, cRegItem.fValue );
std::cout << "CBC " << +pCbc->getCbcId() << " " << cName << ": 0x" << std::hex << +cRegItem.fValue << std::dec << std::endl;
LOG (INFO) << "CBC " << +pCbc->getCbcId() << " " << cName << ": 0x" << std::hex << +cRegItem.fValue << std::dec ;
}
}
......
......@@ -78,36 +78,36 @@ namespace Ph2_HwInterface {
fFileHandler = pHandler;
fSaveToFile = true;
}
else std::cout << "Error, can not set NULL FileHandler" << std::endl;
else LOG (INFO) << "Error, can not set NULL FileHandler" ;
}
uint32_t CtaFWInterface::getBoardInfo()
{
//std::cout << "FMC1 present : " << ReadReg ( "status.fmc1_present" ) << std::endl;
//std::cout << "FMC2 present : " << ReadReg ( "status.fmc2_present" ) << std::endl;
//LOG(INFO) << "FMC1 present : " << ReadReg ( "status.fmc1_present" ) ;
//LOG(INFO) << "FMC2 present : " << ReadReg ( "status.fmc2_present" ) ;
uint32_t cVersionMajor = ReadReg ( "firm_id.firmware_major" );
uint32_t cVersionMinor = ReadReg ( "firm_id.firmware_minor" );
std::cout << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "firm_id.firmware_build" ) << std::endl;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "firm_id.firmware_build" ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "board_id" );
std::cout << "BoardType : ";
LOG (INFO) << "BoardType : ";
char cChar = ( ( cBoardType & cMask4 ) >> 24 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask3 ) >> 16 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask2 ) >> 8 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( cBoardType & cMask1 );
std::cout << cChar << std::endl;
LOG (INFO) << cChar ;
//std::cout << "FMC User Board ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_board_id" ) << std::endl;
//std::cout << "FMC User System ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_sys_id" ) << std::endl;
//std::cout << "FMC User Version : " << ReadReg ( "user_wb_ttc_fmc_regs.user_version" ) << std::endl;
//LOG(INFO) << "FMC User Board ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_board_id" ) ;
//LOG(INFO) << "FMC User System ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_sys_id" ) ;
//LOG(INFO) << "FMC User Version : " << ReadReg ( "user_wb_ttc_fmc_regs.user_version" ) ;
uint32_t cVersionWord = ( (cVersionMajor & 0x0000FFFF) << 16 || (cVersionMinor & 0x0000FFFF) );
return cVersionWord;
......@@ -624,7 +624,7 @@ namespace Ph2_HwInterface {
pRegItem.fPage = ( pWord & cMask6 ) >> 16;
pRegItem.fAddress = ( pWord & cMask2 ) >> 8;
pRegItem.fValue = pWord & cMask1;
//std::cout << "FEID " << +(cbcAddr) << " pCbcID " << +(pCbcId) << std::endl;
//LOG(INFO) << "FEID " << +(cbcAddr) << " pCbcID " << +(pCbcId) ;
}
bool CtaFWInterface::I2cCmdAckWait ( bool bZero, uint8_t pNcount )
......@@ -745,10 +745,10 @@ namespace Ph2_HwInterface {
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 120)
{
std::cout << "There were " << cWriteAgain.size() << " Readback Errors while ckecking I2C writing - trying again!" << std::endl;
LOG (INFO) << "There were " << cWriteAgain.size() << " Readback Errors while ckecking I2C writing - trying again!" ;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else std::cout << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" << std::endl;
//else LOG(INFO) << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" ;
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
}
......@@ -858,8 +858,8 @@ namespace Ph2_HwInterface {
bool CtaFWInterface::cmd_reply_comp (const uint32_t& cWord1, const uint32_t& cWord2)
{
//if (cWord1 != cWord2)
//std::cout << std::endl << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 21) & 0xF) << " CbcId " << + ( (cWord1 >> 17) & 0xF) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord2) << " ### FMCId: " << ( (cWord2 >> 21) & 0xF) << " CbcId " << + ( (cWord2 >> 17) & 0xF) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << std::endl;
//std::cout << "Readback error" << std::endl;
//LOG(INFO) << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 21) & 0xF) << " CbcId " << + ( (cWord1 >> 17) & 0xF) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << " ## " << std::bitset<32> (cWord2) << " ### FMCId: " << ( (cWord2 >> 21) & 0xF) << " CbcId " << + ( (cWord2 >> 17) & 0xF) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) ;
//LOG(INFO) << "Readback error" ;
return ( cWord1 == cWord2 );
}
......
......@@ -73,36 +73,36 @@ namespace Ph2_HwInterface {
fFileHandler = pHandler;
fSaveToFile = true;
}
else std::cout << "Error, can not set NULL FileHandler" << std::endl;
else LOG (INFO) << "Error, can not set NULL FileHandler" ;
}
uint32_t GlibFWInterface::getBoardInfo()
{
std::cout << "FMC1 present : " << ReadReg ( "status.fmc1_present" ) << std::endl;
std::cout << "FMC2 present : " << ReadReg ( "status.fmc2_present" ) << std::endl;
LOG (INFO) << "FMC1 present : " << ReadReg ( "status.fmc1_present" ) ;
LOG (INFO) << "FMC2 present : " << ReadReg ( "status.fmc2_present" ) ;
uint32_t cVersionMajor = ReadReg ( "firm_id.firmware_major" );
uint32_t cVersionMinor = ReadReg ( "firm_id.firmware_minor" );
std::cout << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "firm_id.firmware_build" ) << std::endl;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "firm_id.firmware_build" ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "board_id" );
std::cout << "BoardType : ";
LOG (INFO) << "BoardType : ";
char cChar = ( ( cBoardType & cMask4 ) >> 24 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask3 ) >> 16 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask2 ) >> 8 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( cBoardType & cMask1 );
std::cout << cChar << std::endl;
LOG (INFO) << cChar ;
//std::cout << "FMC User Board ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_board_id" ) << std::endl;
//std::cout << "FMC User System ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_sys_id" ) << std::endl;
//std::cout << "FMC User Version : " << ReadReg ( "user_wb_ttc_fmc_regs.user_version" ) << std::endl;
//LOG(INFO) << "FMC User Board ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_board_id" ) ;
//LOG(INFO) << "FMC User System ID : " << ReadReg ( "user_wb_ttc_fmc_regs.user_sys_id" ) ;
//LOG(INFO) << "FMC User Version : " << ReadReg ( "user_wb_ttc_fmc_regs.user_version" ) ;
uint32_t cVersionWord = ( (cVersionMajor & 0x0000FFFF) << 16 | (cVersionMinor & 0x0000FFFF) );
return cVersionWord;
}
......@@ -601,7 +601,7 @@ namespace Ph2_HwInterface {
WriteReg ( "ctrl_sram.sram1_user_logic", 0 );
pVecReq = ReadBlockRegValue ( "sram1", pVecReqSize );
if (pVecReq.back() != 0xFFFFFFFF) std::cout << "ERROR, the last word read was not 0xFFFFFFFF - not sure if I read all required words!" << std::endl;
if (pVecReq.back() != 0xFFFFFFFF) LOG (INFO) << "ERROR, the last word read was not 0xFFFFFFFF - not sure if I read all required words!" ;
else pVecReq.pop_back();
std::vector< std::pair<std::string, uint32_t> > cVecReg;
......@@ -661,10 +661,10 @@ namespace Ph2_HwInterface {
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 120)
{
std::cout << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" << std::endl;
LOG (INFO) << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" ;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else std::cout << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" << std::endl;
//else LOG(INFO) << "There were too many errors " << cWriteAgain.size() << " (>120 Registers). Something is wrong - aborting!" ;
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
}
......@@ -747,8 +747,8 @@ namespace Ph2_HwInterface {
bool GlibFWInterface::cmd_reply_comp (const uint32_t& cWord1, const uint32_t& cWord2)
{
//if (cWord1 != cWord2)
//std::cout << std::endl << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 21) & 0xF) << " CbcId " << + ( (cWord1 >> 17) & 0xF) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord2) << " ### FMCId: " << ( (cWord2 >> 21) & 0xF) << " CbcId " << + ( (cWord2 >> 17) & 0xF) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << std::endl;
//std::cout << "Readback error" << std::endl;
//LOG(INFO) << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 21) & 0xF) << " CbcId " << + ( (cWord1 >> 17) & 0xF) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << " ## " << std::bitset<32> (cWord2) << " ### FMCId: " << ( (cWord2 >> 21) & 0xF) << " CbcId " << + ( (cWord2 >> 17) & 0xF) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) ;
//LOG(INFO) << "Readback error" ;
return ( cWord1 == cWord2 );
}
......
......@@ -80,33 +80,33 @@ namespace Ph2_HwInterface {
fFileHandler = pHandler;
fSaveToFile = true;
}
else std::cout << "Error, can not set NULL FileHandler" << std::endl;
else LOG (INFO) << "Error, can not set NULL FileHandler" ;
}
uint32_t ICFc7FWInterface::getBoardInfo()
{
//std::cout << "FMC1 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc0" ) << std::endl;
//std::cout << "FMC2 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc1" ) << std::endl;
//LOG(INFO) << "FMC1 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc0" ) ;
//LOG(INFO) << "FMC2 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc1" ) ;
uint32_t cVersionMajor, cVersionMinor;
cVersionMajor = ReadReg ( "user_stat.version.ver_major" );
cVersionMinor = ReadReg ( "user_stat.version.ver_minor" );
std::cout << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "user_stat.version.ver_build" ) << std::endl;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "user_stat.version.ver_build" ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "sys_regs.board_id" );
std::cout << "BoardType : ";
LOG (INFO) << "BoardType : ";
char cChar = ( ( cBoardType & cMask4 ) >> 24 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask3 ) >> 16 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask2 ) >> 8 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( cBoardType & cMask1 );
std::cout << cChar << std::endl;
LOG (INFO) << cChar ;
uint32_t cVersionWord = ( (cVersionMajor & 0x0000FFFF) << 16 || (cVersionMinor & 0x0000FFFF) );
return cVersionWord;
......@@ -124,9 +124,9 @@ namespace Ph2_HwInterface {
bool cfmc2_en = ReadReg ("user_stat.fw_cnfg.fmc_cnfg.fmc2_cbc_en");
bool cDIO5_en = ReadReg ("user_stat.fw_cnfg.dio5ch_xtrig_en");
fBroadcastCbcId = ReadReg ("user_stat.fw_cnfg.fmc_cnfg.ncbc_per_fmc");
std::cout << "FMC1 en: " << cfmc1_en << std::endl << "FMC2 en: " << cfmc2_en << std::endl << "Number of CBCs: " << fBroadcastCbcId << std::endl;
std::cout << "DIO5 en: " << cDIO5_en << std::endl;
std::cout << "Number of 32-bit words/Event in this configuration: " << fDataSizeperEvent32 << std::endl;
LOG (INFO) << "FMC1 en: " << cfmc1_en << "FMC2 en: " << cfmc2_en << "Number of CBCs: " << fBroadcastCbcId ;
LOG (INFO) << "DIO5 en: " << cDIO5_en ;
LOG (INFO) << "Number of 32-bit words/Event in this configuration: " << fDataSizeperEvent32 ;
//this does not work because BeBoard* is const
//pBoard->setNCbcDataSize(uint16_t(cNCbcperFMC));
......@@ -188,8 +188,8 @@ namespace Ph2_HwInterface {
for (auto& cWord : pReplies)
cSuccess = ( ( (cWord >> 20) & 0x1) == 0 && ( (cWord) & 0x000000FF) != 0 ) ? true : false;
if (cSuccess) std::cout << "Successfully received *Pings* from " << fBroadcastCbcId << " Cbcs on FMC " << +fFMCId << std::endl;
else std::cout << "Error, did not receive the correct number of *Pings*; expected: " << fBroadcastCbcId << ", received: " << pReplies.size() << std::endl;
if (cSuccess) LOG (INFO) << "Successfully received *Pings* from " << fBroadcastCbcId << " Cbcs on FMC " << +fFMCId ;
else LOG (INFO) << "Error, did not receive the correct number of *Pings*; expected: " << fBroadcastCbcId << ", received: " << pReplies.size() ;
cVecReg.push_back ({"cbc_daq_ctrl.cbc_i2c_ctrl", 0x2});
WriteStackReg ( cVecReg );
......@@ -292,7 +292,7 @@ namespace Ph2_HwInterface {
cNCycles = ceil (pNEvents / double (cNEvents) );
}
std::cout << "Packet Size larger than 2000, splitting in Acquisitions of " << cNEvents << " in " << cNCycles << " cycles!" << std::endl;
LOG (INFO) << "Packet Size larger than 2000, splitting in Acquisitions of " << cNEvents << " in " << cNCycles << " cycles!" ;
}
std::vector< std::pair<std::string, uint32_t> > cVecReg;
......@@ -443,7 +443,7 @@ namespace Ph2_HwInterface {
if (cNReplies != pNReplies)
{
std::cout << "Error: Read " << cNReplies << " I2C replies whereas " << pNReplies << " are expected!" << std::endl;
LOG (INFO) << "Error: Read " << cNReplies << " I2C replies whereas " << pNReplies << " are expected!" ;
cFailed = true;
}
......@@ -538,7 +538,7 @@ namespace Ph2_HwInterface {
//uint32_t cWord1 = pVecReg.at (index);
//uint32_t cWord2 = cReplies.at (2 * index);
//uint32_t cWord3 = cReplies.at ( (2 * index) + 1);
//std::cout << std::endl << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord3) << " ### Read: CbcId " << + ( (cWord3 >> 24) & 0xF) << " Info " << + ( (cWord3 >> 20) & 0x1) << " Read? " << + ( (cWord3 >> 17) & 0x1) << " Page " << + ( (cWord3 >> 16) & 0x1) << " Address " << + ( (cWord3 >> 8) & 0xFF) << " Value " << + ( (cWord3) & 0xFF) << std::endl;
//LOG(INFO) << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << " ## " << std::bitset<32> (cWord3) << " ### Read: CbcId " << + ( (cWord3 >> 24) & 0xF) << " Info " << + ( (cWord3 >> 20) & 0x1) << " Read? " << + ( (cWord3 >> 17) & 0x1) << " Page " << + ( (cWord3 >> 16) & 0x1) << " Address " << + ( (cWord3 >> 8) & 0xFF) << " Value " << + ( (cWord3) & 0xFF) ;
//;
//}
......@@ -579,12 +579,12 @@ namespace Ph2_HwInterface {
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 100)
{
if (pReadback) std::cout << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" << std::endl;
else std::cout << "There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" << std::endl;
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!" ;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else std::cout << "There were too many errors (>100 Registers). Something is wrong - aborting!" << std::endl;
//else LOG(INFO) << "There were too many errors (>100 Registers). Something is wrong - aborting!" ;
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
......@@ -615,7 +615,7 @@ namespace Ph2_HwInterface {
else
cSuccess = false;
//std::cout << std::bitset<32>(cWord) << std::endl;
//LOG(INFO) << std::bitset<32>(cWord) ;
}
//cWriteAgain = get_mismatches (pVecReg.begin(), pVecReg.end(), cReplies.begin(), ICFc7FWInterface::cmd_reply_ack);
......@@ -706,7 +706,7 @@ namespace Ph2_HwInterface {
{
//TODO: cleanup
//if ( (cWord1 & 0x0F00FFFF) != (cWord2 & 0x0F00FFFF) )
//std::cout << std::endl << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << std::endl;
//LOG(INFO) << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) ;
//if the Register is FrontEndControl at p0 addr0, page is not defined and therefore I ignore it!
if ( ( (cWord1 >> 16) & 0x1) == 0 && ( (cWord1 >> 8 ) & 0xFF) == 0) return ( (cWord1 & 0x0F00FFFF) == (cWord2 & 0x0F00FFFF) );
......
......@@ -80,33 +80,33 @@ namespace Ph2_HwInterface {
fFileHandler = pHandler;
fSaveToFile = true;
}
else std::cout << "Error, can not set NULL FileHandler" << std::endl;
else LOG (INFO) << "Error, can not set NULL FileHandler" ;
}
uint32_t ICGlibFWInterface::getBoardInfo()
{
//std::cout << "FMC1 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc0" ) << std::endl;
//std::cout << "FMC2 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc1" ) << std::endl;
//LOG(INFO) << "FMC1 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc0" ) ;
//LOG(INFO) << "FMC2 present : " << ReadReg ( "user_stat.current_fec_fmc2_cbc1" ) ;
uint32_t cVersionMajor, cVersionMinor;
cVersionMajor = ReadReg ( "user_stat.version.ver_major" );
cVersionMinor = ReadReg ( "user_stat.version.ver_minor" );
std::cout << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "user_stat.version.ver_build" ) << std::endl;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "user_stat.version.ver_build" ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "sys_regs.board_id" );
std::cout << "BoardType : ";
LOG (INFO) << "BoardType : ";
char cChar = ( ( cBoardType & cMask4 ) >> 24 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask3 ) >> 16 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( ( cBoardType & cMask2 ) >> 8 );
std::cout << cChar;
LOG (INFO) << cChar;
cChar = ( cBoardType & cMask1 );
std::cout << cChar << std::endl;
LOG (INFO) << cChar ;
uint32_t cVersionWord = ( (cVersionMajor & 0x0000FFFF) << 16 || (cVersionMinor & 0x0000FFFF) );
return cVersionWord;
......@@ -124,9 +124,9 @@ namespace Ph2_HwInterface {
bool cfmc2_en = ReadReg ("user_stat.fw_cnfg.fmc_cnfg.fmc2_cbc_en");
bool cDIO5_en = ReadReg ("user_stat.fw_cnfg.dio5ch_xtrig_en");
fBroadcastCbcId = ReadReg ("user_stat.fw_cnfg.fmc_cnfg.ncbc_per_fmc");
std::cout << "FMC1 en: " << cfmc1_en << std::endl << "FMC2 en: " << cfmc2_en << std::endl << "Number of CBCs: " << fBroadcastCbcId << std::endl;
std::cout << "DIO5 en: " << cDIO5_en << std::endl;
std::cout << "Number of 32-bit words/Event in this configuration: " << fDataSizeperEvent32 << std::endl;
LOG (INFO) << "FMC1 en: " << cfmc1_en << "FMC2 en: " << cfmc2_en << "Number of CBCs: " << fBroadcastCbcId ;
LOG (INFO) << "DIO5 en: " << cDIO5_en ;
LOG (INFO) << "Number of 32-bit words/Event in this configuration: " << fDataSizeperEvent32 ;
//this does not work because BeBoard* is const
//pBoard->setNCbcDataSize(uint16_t(cNCbcperFMC));
......@@ -186,8 +186,8 @@ namespace Ph2_HwInterface {
for (auto& cWord : pReplies)
cSuccess = ( ( (cWord >> 20) & 0x1) == 0 && ( (cWord) & 0x000000FF) != 0 ) ? true : false;
if (cSuccess) std::cout << "Successfully received *Pings* from " << fBroadcastCbcId << " Cbcs on FMC " << +fFMCId << std::endl;
else std::cout << "Error, did not receive the correct number of *Pings*; expected: " << fBroadcastCbcId << ", received: " << pReplies.size() << std::endl;
if (cSuccess) LOG (INFO) << "Successfully received *Pings* from " << fBroadcastCbcId << " Cbcs on FMC " << +fFMCId ;
else LOG (INFO) << "Error, did not receive the correct number of *Pings*; expected: " << fBroadcastCbcId << ", received: " << pReplies.size() ;
cVecReg.push_back ({"cbc_daq_ctrl.cbc_i2c_ctrl", 0x2});
WriteStackReg ( cVecReg );
......@@ -290,7 +290,7 @@ namespace Ph2_HwInterface {
cNCycles = ceil (pNEvents / double (cNEvents) );
}
std::cout << "Packet Size larger than 2000, splitting in Acquisitions of " << cNEvents << " in " << cNCycles << " cycles!" << std::endl;
LOG (INFO) << "Packet Size larger than 2000, splitting in Acquisitions of " << cNEvents << " in " << cNCycles << " cycles!" ;
}
std::vector< std::pair<std::string, uint32_t> > cVecReg;
......@@ -441,7 +441,7 @@ namespace Ph2_HwInterface {
if (cNReplies != pNReplies)
{
std::cout << "Error: Read " << cNReplies << " I2C replies whereas " << pNReplies << " are expected!" << std::endl;
LOG (INFO) << "Error: Read " << cNReplies << " I2C replies whereas " << pNReplies << " are expected!" ;
cFailed = true;
}
......@@ -536,7 +536,7 @@ namespace Ph2_HwInterface {
//uint32_t cWord1 = pVecReg.at (index);
//uint32_t cWord2 = cReplies.at (2 * index);
//uint32_t cWord3 = cReplies.at ( (2 * index) + 1);
//std::cout << std::endl << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord3) << " ### Read: CbcId " << + ( (cWord3 >> 24) & 0xF) << " Info " << + ( (cWord3 >> 20) & 0x1) << " Read? " << + ( (cWord3 >> 17) & 0x1) << " Page " << + ( (cWord3 >> 16) & 0x1) << " Address " << + ( (cWord3 >> 8) & 0xFF) << " Value " << + ( (cWord3) & 0xFF) << std::endl;
//LOG(INFO) << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << " ## " << std::bitset<32> (cWord3) << " ### Read: CbcId " << + ( (cWord3 >> 24) & 0xF) << " Info " << + ( (cWord3 >> 20) & 0x1) << " Read? " << + ( (cWord3 >> 17) & 0x1) << " Page " << + ( (cWord3 >> 16) & 0x1) << " Address " << + ( (cWord3 >> 8) & 0xFF) << " Value " << + ( (cWord3) & 0xFF) ;
//;
//}
......@@ -577,12 +577,12 @@ namespace Ph2_HwInterface {
// if the number of errors is greater than 100, give up
if (cWriteAgain.size() < 100)
{
if (pReadback) std::cout << "There were " << cWriteAgain.size() << " Readback Errors -trying again!" << std::endl;
else std::cout << "There were " << cWriteAgain.size() << " CBC CMD acknowledge bits missing -trying again!" << std::endl;
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!" ;
this->WriteCbcBlockReg ( cWriteAgain, true);
}
//else std::cout << "There were too many errors (>100 Registers). Something is wrong - aborting!" << std::endl;
//else LOG(INFO) << "There were too many errors (>100 Registers). Something is wrong - aborting!" ;
else throw Exception ( "Too many CBC readback errors - no functional I2C communication. Check the Setup" );
}
......@@ -613,7 +613,7 @@ namespace Ph2_HwInterface {
else
cSuccess = false;
//std::cout << std::bitset<32>(cWord) << std::endl;
//LOG(INFO) << std::bitset<32>(cWord) ;
}
//cWriteAgain = get_mismatches (pVecReg.begin(), pVecReg.end(), cReplies.begin(), ICGlibFWInterface::cmd_reply_ack);
......@@ -685,7 +685,7 @@ namespace Ph2_HwInterface {
{
//TODO: cleanup
if ( (cWord1 & 0x0F00FFFF) != (cWord2 & 0x0F00FFFF) )
std::cout << std::endl << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << std::endl << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) << std::endl;
LOG (INFO) << " ## " << std::bitset<32> (cWord1) << " ### Written: FMCId " << + ( (cWord1 >> 28) & 0xF) << " CbcId " << + ( (cWord1 >> 24) & 0xF) << " Read " << + ( (cWord1 >> 21) & 0x1) << " Write " << + ( (cWord1 >> 20) & 0x1) << " Page " << + ( (cWord1 >> 16) & 0x1) << " Address " << + ( (cWord1 >> 8) & 0xFF) << " Value " << + ( (cWord1) & 0xFF) << " ## " << std::bitset<32> (cWord2) << " ### Read: CbcId " << + ( (cWord2 >> 24) & 0xF) << " Info " << + ( (cWord2 >> 20) & 0x1) << " Read? " << + ( (cWord2 >> 17) & 0x1) << " Page " << + ( (cWord2 >> 16) & 0x1) << " Address " << + ( (cWord2 >> 8) & 0xFF) << " Value " << + ( (cWord2) & 0xFF) ;
//if the Register is FrontEndControl at p0 addr0, page is not defined and therefore I ignore it!
if ( ( (cWord1 >> 16) & 0x1) == 0 && ( (cWord1 >> 8 ) & 0xFF) == 0) return ( (cWord1 & 0x0F00FFFF) == (cWord2 & 0x0F00FFFF) );
......
......@@ -15,312 +15,322 @@
#define DEV_FLAG 0
namespace Ph2_HwInterface
{
std::string RegManager::strDummyXml="file://HWInterface/dummy.xml";
namespace Ph2_HwInterface {
std::string RegManager::strDummyXml = "file://HWInterface/dummy.xml";
RegManager::RegManager( const char* puHalConfigFileName, uint32_t pBoardId ) :
fThread( [ = ]
{
StackWriteTimeOut();
} ),
fDeactiveThread( false )
{
// Loging settings
uhal::disableLogging();
//uhal::setLogLevelTo(uhal::Error()); //Raise the log level
RegManager::RegManager ( const char* puHalConfigFileName, uint32_t pBoardId ) :
fThread ( [ = ]
{
StackWriteTimeOut();
} ),
fDeactiveThread ( false )
{
// Loging settings
uhal::disableLogging();
//uhal::setLogLevelTo(uhal::Error()); //Raise the log level
fUHalConfigFileName = puHalConfigFileName;
fUHalConfigFileName = puHalConfigFileName;
uhal::ConnectionManager cm( fUHalConfigFileName ); // Get connection
char cBuff[7];
sprintf( cBuff, "board%d", pBoardId );
uhal::ConnectionManager cm ( fUHalConfigFileName ); // Get connection
char cBuff[7];