Skip to content

Commit

Permalink
Checkpoint in initial hardware event building development
Browse files Browse the repository at this point in the history
  • Loading branch information
rrivera747 committed Jan 9, 2025
1 parent 5841282 commit 7a60888
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dtcInterfaceLib/CFOandDTC_Registers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ DTCLib::RegisterFormatter DTCLib::CFOandDTC_Registers::FormatJitterAttenuatorCSR
form.description = "Jitter Attenuator CSR";
form.vals.push_back("<field> : [<value>]"); //first value describes format
form.vals.push_back(std::string("JA Source Clock Select: [") +
(JAinputSelect.to_ulong() == 0 ? "from CFO"
(JAinputSelect.to_ulong() == 0 ? "from emulated CFO"
: (JAinputSelect.to_ulong() == 1 ? "from RJ45"
: "Timing Card Selectable (SFP+ or FPGA) Input Clock")) + "]");
form.vals.push_back(std::string("JA in Reset: [") + (data[0] ? "YES" : "No") + "]");
Expand Down
2 changes: 1 addition & 1 deletion dtcInterfaceLib/DTC_Registers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3723,7 +3723,7 @@ void DTCLib::DTC_Registers::SetCFO40MHzClockMarkerEnable(DTC_Link_ID const& link
std::bitset<32> data = ReadRegister_(DTC_Register_CFOMarkerEnables);
if (link == DTC_Link_ALL)
{
for (uint8_t i = 0; i < 8; ++i)
for (uint8_t i = 0; i < 6; ++i) //just ROC links
data[i] = enable;
}
else
Expand Down
28 changes: 27 additions & 1 deletion dtcInterfaceLib/mu2edev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ int mu2edev::init(DTCLib::DTC_SimMode simMode, int deviceIndex, std::string simM
return simMode;
}

//==============================================================================
// exec
// run linux command and get result back in string
std::string exec(const char* cmd)
{
__COUTV__(cmd);

std::array<char, 128> buffer;
std::string result;
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
if(!pipe)
{
__COUT_ERR__ << "popen() failed!" << __E__;
return "popen() failed!";
}
while(!feof(pipe.get()))
{
if(fgets(buffer.data(), 128, pipe.get()) != nullptr)
result += buffer.data();
}
//__COUTV__(result);
return result;
} // end exec()

/*****************************
initDMAEngine
set up DMA engines
Expand All @@ -111,7 +135,9 @@ void mu2edev::initDMAEngine()
__SS__ << "mu2e Device file not found (or DTCLIB_SIM_ENABLE not set)! Exiting.\n" <<
"Attempt to open '" << devfile << "' and received error: " << errno << " - " <<
strerror(errno) << __E__;
perror(ss.str().c_str());

ss << "Who owns it?\n" << exec("ls -l /dev/mu2e*") << __E__;
perror(ss.str().c_str());
__SS_THROW__;
// exit(1);
}
Expand Down

0 comments on commit 7a60888

Please sign in to comment.