mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
slsReceiver: removed special receiver config, added rx_dbitlist, rx_dbitoffset to put bits together in file, connected adcinvert, extsamplingsrc and extsampling properly to the detector, added tests
This commit is contained in:
@ -2446,22 +2446,18 @@ const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
|
||||
}
|
||||
|
||||
void multiSlsDetector::setADCEnableMask(uint32_t mask, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setADCEnableMask(mask);
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::setADCEnableMask, mask);
|
||||
}
|
||||
|
||||
uint32_t multiSlsDetector::getADCEnableMask(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getADCEnableMask();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::getADCEnableMask);
|
||||
if (sls::allEqual(r)) {
|
||||
return r.front();
|
||||
@ -2471,6 +2467,96 @@ uint32_t multiSlsDetector::getADCEnableMask(int detPos) {
|
||||
throw RuntimeError("Error: Different Values for function getADCEnableMask");
|
||||
}
|
||||
|
||||
void multiSlsDetector::setADCInvert(uint32_t value, int detPos) {
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setADCInvert(value);
|
||||
}
|
||||
|
||||
parallelCall(&slsDetector::setADCInvert, value);
|
||||
}
|
||||
|
||||
uint32_t multiSlsDetector::getADCInvert(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getADCInvert();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::getADCInvert);
|
||||
if (sls::allEqual(r)) {
|
||||
return r.front();
|
||||
}
|
||||
|
||||
// can't have different values
|
||||
throw RuntimeError("Error: Different Values for function getADCInvert");
|
||||
}
|
||||
|
||||
void multiSlsDetector::setExternalSamplingSource(int value, int detPos) {
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setExternalSamplingSource(value);
|
||||
}
|
||||
|
||||
parallelCall(&slsDetector::setExternalSamplingSource, value);
|
||||
}
|
||||
|
||||
int multiSlsDetector::getExternalSamplingSource(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getExternalSamplingSource();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::getExternalSamplingSource);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::setExternalSampling(bool value, int detPos) {
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setExternalSampling(static_cast<int>(value));
|
||||
}
|
||||
|
||||
parallelCall(&slsDetector::setExternalSampling, static_cast<int>(value));
|
||||
}
|
||||
|
||||
int multiSlsDetector::getExternalSampling(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getExternalSampling();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::getExternalSampling);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::setReceiverDbitList(std::vector<int> list, int detPos) {
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setReceiverDbitList(list);
|
||||
}
|
||||
|
||||
parallelCall(&slsDetector::setReceiverDbitList, list);
|
||||
}
|
||||
|
||||
std::vector<int> multiSlsDetector::getReceiverDbitList(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getReceiverDbitList();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::getReceiverDbitList);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::setReceiverDbitOffset(int value, int detPos) {
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setReceiverDbitOffset(value);
|
||||
}
|
||||
|
||||
parallelCall(&slsDetector::setReceiverDbitOffset, value);
|
||||
}
|
||||
|
||||
int multiSlsDetector::getReceiverDbitOffset(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getReceiverDbitOffset();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::getReceiverDbitOffset);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::writeAdcRegister(uint32_t addr, uint32_t val, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
|
@ -393,6 +393,9 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->rxFileWrite = true;
|
||||
shm()->rxMasterFileWrite = true;
|
||||
shm()->rxFileOverWrite = true;
|
||||
shm()->rxDbitListSize = 0;
|
||||
memset(shm()->rxDbitList, 0, MAX_RX_DBIT * sizeof(int));
|
||||
shm()->rxDbitOffset = 0;
|
||||
|
||||
// get the detector parameters based on type
|
||||
detParameters parameters{type};
|
||||
@ -1908,6 +1911,8 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
<< "\nrx streaming source ip:" << shm()->rxZmqip
|
||||
<< "\nrx additional json header:" << shm()->rxAdditionalJsonHeader
|
||||
<< "\nrx_datastream:" << enableDataStreamingFromReceiver(-1)
|
||||
<< "\nrx_dbitlistsize:" << shm()->rxDbitListSize
|
||||
<< "\nrx_DbitOffset:" << shm()->rxDbitOffset
|
||||
<< std::endl;
|
||||
|
||||
if (setDetectorType(shm()->myDetectorType) != GENERIC) {
|
||||
@ -1954,6 +1959,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
enableTenGigabitEthernet(shm()->tenGigaEnable);
|
||||
setReadOutFlags(GET_READOUT_FLAGS);
|
||||
setADCEnableMask(shm()->adcEnableMask);
|
||||
setReceiverDbitOffset(shm()->rxDbitOffset);
|
||||
break;
|
||||
|
||||
case MOENCH:
|
||||
@ -1971,6 +1977,11 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
std::vector<int> list(shm()->rxDbitList, shm()->rxDbitList + shm()->rxDbitListSize);
|
||||
setReceiverDbitList(list);
|
||||
}
|
||||
|
||||
setReceiverSilentMode(static_cast<int>(shm()->rxSilentMode));
|
||||
// data streaming
|
||||
setReceiverStreamingFrequency(shm()->rxReadFreq);
|
||||
@ -2666,6 +2677,143 @@ uint32_t slsDetector::getADCEnableMask() {
|
||||
return shm()->adcEnableMask;
|
||||
}
|
||||
|
||||
void slsDetector::setADCInvert(uint32_t value) {
|
||||
uint32_t arg = value;
|
||||
FILE_LOG(logDEBUG1) << "Setting ADC Invert to 0x" << std::hex << arg << std::dec;
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
sendToDetector(F_SET_ADC_INVERT, &arg, sizeof(arg), nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t slsDetector::getADCInvert() {
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting ADC Invert";
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
sendToDetector(F_GET_ADC_INVERT, nullptr, 0, &retval, sizeof(retval));
|
||||
FILE_LOG(logDEBUG1) << "ADC Invert: 0x" << std::hex << retval << std::dec;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::setExternalSamplingSource(int value) {
|
||||
int arg = value;
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Setting External Sampling Source to " << arg;
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
sendToDetector(F_EXTERNAL_SAMPLING_SOURCE, arg, retval);
|
||||
FILE_LOG(logDEBUG1) << "External Sampling source: " << retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getExternalSamplingSource() {
|
||||
return setExternalSamplingSource(-1);
|
||||
}
|
||||
|
||||
int slsDetector::setExternalSampling(int value) {
|
||||
int arg = value;
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Setting External Sampling to " << arg;
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
sendToDetector(F_EXTERNAL_SAMPLING, arg, retval);
|
||||
FILE_LOG(logDEBUG1) << "External Sampling: " << retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getExternalSampling() {
|
||||
return setExternalSampling(-1);
|
||||
}
|
||||
|
||||
void slsDetector::setReceiverDbitList(std::vector<int> list) {
|
||||
FILE_LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
||||
|
||||
if (list.size() > 64) {
|
||||
throw sls::RuntimeError("Dbit list size cannot be greater than 64\n");
|
||||
}
|
||||
for (auto &it : list) {
|
||||
if (it < 0 || it > 63) {
|
||||
throw sls::RuntimeError("Dbit list value must be between 0 and 63\n");
|
||||
}
|
||||
}
|
||||
|
||||
// copy size and vector to shm
|
||||
shm()->rxDbitListSize = list.size();
|
||||
std::copy(list.begin(), list.end(), shm()->rxDbitList);
|
||||
|
||||
int ret = FAIL;
|
||||
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
|
||||
int fnum = F_SET_RECEIVER_DBIT_LIST;
|
||||
int arg = list.size();
|
||||
auto receiver =
|
||||
sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.sendData(&fnum, sizeof(fnum));
|
||||
receiver.sendData(&arg, sizeof(arg));
|
||||
receiver.sendData(shm()->rxDbitList, arg * sizeof(int));
|
||||
receiver.receiveData(&ret, sizeof(ret));
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
receiver.receiveData(mess, MAX_STR_LENGTH);
|
||||
throw ReceiverError("Receiver " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
}
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateCachedReceiverVariables();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> slsDetector::getReceiverDbitList() {
|
||||
int fnum = F_GET_RECEIVER_DBIT_LIST;
|
||||
int ret = FAIL;
|
||||
std::vector <int> retval;
|
||||
int retsize = 0;
|
||||
FILE_LOG(logDEBUG1) << "Getting Receiver Dbit List";
|
||||
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
|
||||
auto receiver =
|
||||
sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.sendData(&fnum, sizeof(fnum));
|
||||
receiver.receiveData(&ret, sizeof(ret));
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
receiver.receiveData(mess, MAX_STR_LENGTH);
|
||||
throw ReceiverError("Receiver " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
}
|
||||
receiver.receiveData(&retsize, sizeof(retsize));
|
||||
int list[retsize];
|
||||
receiver.receiveData(list, sizeof(list));
|
||||
|
||||
// copy after no errors
|
||||
shm()->rxDbitListSize = retsize;
|
||||
std::copy(list, list + retsize, shm()->rxDbitList);
|
||||
}
|
||||
|
||||
if (shm()->rxDbitListSize) {
|
||||
retval.resize(shm()->rxDbitListSize);
|
||||
std::copy(shm()->rxDbitList, shm()->rxDbitList + shm()->rxDbitListSize, std::begin(retval));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::setReceiverDbitOffset(int value) {
|
||||
int arg = value;
|
||||
int retval = -1;
|
||||
if (value >= 0)
|
||||
shm()->rxDbitOffset = value;
|
||||
FILE_LOG(logDEBUG1) << "Setting digital bit offset in receiver to " << arg;
|
||||
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
|
||||
sendToReceiver(F_RECEIVER_DBIT_OFFSET, arg, retval);
|
||||
FILE_LOG(logDEBUG1) << "Receiver digital bit offset: " << retval;
|
||||
}
|
||||
return shm()->rxDbitOffset;
|
||||
}
|
||||
|
||||
int slsDetector::getReceiverDbitOffset() {
|
||||
return shm()->rxDbitOffset;
|
||||
}
|
||||
|
||||
int slsDetector::writeAdcRegister(uint32_t addr, uint32_t val) {
|
||||
uint32_t args[]{addr, val};
|
||||
FILE_LOG(logDEBUG1) << "Writing to ADC register 0x" << std::hex << addr
|
||||
@ -3295,6 +3443,21 @@ int slsDetector::updateCachedReceiverVariables() const {
|
||||
n += receiver.receiveData(&i32, sizeof(i32));
|
||||
shm()->rxSilentMode = static_cast<bool>(i32);
|
||||
|
||||
// dbit list size
|
||||
{
|
||||
int listsize = 0;
|
||||
n += receiver.receiveData(&listsize, sizeof(listsize));
|
||||
int list[listsize];
|
||||
n += receiver.receiveData(list, sizeof(list));
|
||||
// copy after no errors
|
||||
shm()->rxDbitListSize = listsize;
|
||||
std::copy(list, list + listsize, shm()->rxDbitList);
|
||||
}
|
||||
|
||||
// dbit offset
|
||||
n += receiver.receiveData(&i32, sizeof(i32));
|
||||
shm()->rxDbitOffset = i32;
|
||||
|
||||
if (n == 0) {
|
||||
throw RuntimeError("Could not update receiver: " +
|
||||
std::string(shm()->rxHostname) +
|
||||
|
@ -1934,13 +1934,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>adcinvert [mask]</b> Sets/gets ADC inversion mask (8 digits hex format)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "adcinvert";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>adcenable [mask]</b> Sets/gets ADC enable mask (8 digits hex format)
|
||||
*/
|
||||
@ -1948,11 +1941,46 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/** not documenting this, but keeping this for backwards compatibility */
|
||||
/** not documenting this, but keeping this for backwards compatibility */
|
||||
descrToFuncMap[i].m_pFuncName = "adcdisable";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>adcinvert [mask]</b> Sets/gets ADC inversion mask (8 digits hex format) CTB or Moench only
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "adcinvert";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>extsamplingsrc [i]</b> sets/gets the sampling source signal for digital data. \ci must be between 0 and 63. Advanced! CTB only \Returns (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "extsamplingsrc";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>extsampling [i]</b> enables/disables the external sampling signal to the \c samplingsrc signal for digital data. Advanced! CTB only \Returns (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "extsampling";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>rx_dbitlist [i]</b> sets/gets the list of digital signal bits required for chip in receiver. If set to "all", then all digital bits are enabled. Advanced! CTB only \Returns (string)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "rx_dbitlist";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>rx_dbitoffset [i]</b> sets/gets the offset in bytes in receiver of digital data from chip in receiver. Advanced! CTB only \Returns (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "rx_dbitoffset";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>pattern fn</b> loads binary pattern file fn
|
||||
*/
|
||||
@ -2086,13 +2114,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
/*! \page prototype
|
||||
- <b>dut_clk [i]</b> sets/gets the signal to be used as a clock for the digital data coming from the device under test. Advanced!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "dut_clk";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||
++i;
|
||||
|
||||
numberOfCommands = i;
|
||||
|
||||
// #ifdef VERBOSE
|
||||
@ -5233,8 +5254,12 @@ std::string slsDetectorCommand::helpPattern(int action) {
|
||||
os << "patwaittime2 nclk \t sets wait 2 waiting time in clock number " << std::endl;
|
||||
os << "patmask m \t sets the 64 bit mask (hex) applied to every pattern. Only the bits from patsetbit are selected to mask for the corresponding bit value from m mask" << std::endl;
|
||||
os << "patsetbit m \t selects bits (hex) of the 64 bits that the patmask will be applied to every pattern. Only the bits from m mask are selected to mask for the corresponding bit value from patmask." << std::endl;
|
||||
os << "adcinvert mask\t sets the adcinversion mask (hex)" << std::endl;
|
||||
os << "adcenable mask\t sets the adcenable mask (hex)" << std::endl;
|
||||
os << "adcinvert mask\t sets the adcinversion mask (hex) CTB or Moench only" << std::endl;
|
||||
os << "adcenable mask\t sets the adcenable mask (hex) CTB or Moench only" << std::endl;
|
||||
os << "extsamplingsrc i\t sets the external sampling source signal for digital data. i must be between 0 and 63. Advanced! CTB only " << std::endl;
|
||||
os << "extsampling i\t enables/disables the external sampling signal to the samplingsrc signal for digital data. Advanced! CTB only" << std::endl;
|
||||
os << "rx_dbitlist i..\t sets the list of digital signal bits required for chip in receiver. If set to 'all', then all digital bits are enabled. Advanced! CTB only " << std::endl;
|
||||
os << "rx_dbitoffset i\t sets the offset in bytes in receiver of digital data from chip in receiver. Advanced! CTB only " << std::endl;
|
||||
}
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << "pattern \t cannot get" << std::endl;
|
||||
@ -5257,8 +5282,12 @@ std::string slsDetectorCommand::helpPattern(int action) {
|
||||
os << "patmask \t gets the 64 bit mask (hex) applied to every pattern." << std::endl;
|
||||
os << "patsetbit \t gets 64 bit mask (hex) of the selected bits that the patmask will be applied to every pattern. " << std::endl;
|
||||
os << "adcinvert \t returns the adcinversion mask " << std::endl;
|
||||
|
||||
os << "adcenable \t returns the adcenable mask " << std::endl;
|
||||
os << "extsamplingsrc \t gets the external sampling source signal for digital data. i must be between 0 and 63. Advanced! CTB only " << std::endl;
|
||||
os << "extsampling \t gets the external sampling signal enable to the samplingsrc signal for digital data. Advanced! CTB only" << std::endl;
|
||||
os << "rx_dbitlist \t gets the list of digital signal bits required for chip in receiver. If value is 'all', all digital bits are enabled. Advanced! CTB only " << std::endl;
|
||||
os << "rx_dbitoffset \t gets the offset in bytes in receiver of digital data from chip in receiver. Advanced! CTB only " << std::endl;
|
||||
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
@ -5274,6 +5303,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
|
||||
**********/
|
||||
std::string fname;
|
||||
int addr, start, stop, n;
|
||||
uint32_t u32;
|
||||
uint64_t word, t;
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
@ -5589,41 +5619,15 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
|
||||
|
||||
os << "0x" << std::hex << myDet->getPatternBitMask(detPos) << std::dec;
|
||||
|
||||
} else if (cmd == "adcinvert") {
|
||||
if (action == PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1], "%x", &addr))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan adcinvert reg ") + std::string(args[1]);
|
||||
|
||||
myDet->writeRegister(67, addr, detPos);
|
||||
}
|
||||
|
||||
os << std::hex << myDet->readRegister(67, detPos) << std::dec ;
|
||||
|
||||
} else if (cmd == "dut_clk") {
|
||||
if (action == PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1], "%x", &addr))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan dut_clk reg ") + std::string(args[1]);
|
||||
|
||||
myDet->writeRegister(123, addr, detPos); //0x7b
|
||||
}
|
||||
|
||||
os << std::hex << myDet->readRegister(123, detPos) << std::dec ; //0x7b
|
||||
} else if (cmd == "adcenable") {
|
||||
} else if (cmd == "adcenable") {
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
uint32_t adcEnableMask = 0;
|
||||
if (sscanf(args[1], "%x", &adcEnableMask))
|
||||
if (sscanf(args[1], "%x", &u32))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan adcenable reg ") + std::string(args[1]);
|
||||
|
||||
myDet->setADCEnableMask(adcEnableMask, detPos);
|
||||
myDet->setADCEnableMask(u32, detPos);
|
||||
}
|
||||
|
||||
os << std::hex << myDet->getADCEnableMask(detPos) << std::dec;
|
||||
@ -5632,22 +5636,109 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
|
||||
else if (cmd == "adcdisable") {
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
uint32_t adcEnableMask = 0;
|
||||
if (sscanf(args[1], "%x", &adcEnableMask))
|
||||
if (sscanf(args[1], "%x", &u32))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan adcdisable reg ") + std::string(args[1]);
|
||||
|
||||
// get enable mask from enable mask
|
||||
adcEnableMask ^= BIT32_MASK;
|
||||
myDet->setADCEnableMask(adcEnableMask, detPos);
|
||||
u32 ^= BIT32_MASK;
|
||||
myDet->setADCEnableMask(u32, detPos);
|
||||
}
|
||||
|
||||
uint32_t retval = myDet->getADCEnableMask(detPos);
|
||||
u32 = myDet->getADCEnableMask(detPos);
|
||||
// get disable mask
|
||||
retval ^= BIT32_MASK;
|
||||
os << std::hex << retval << std::dec;
|
||||
}
|
||||
u32 ^= BIT32_MASK;
|
||||
os << std::hex << u32 << std::dec;
|
||||
|
||||
} else if (cmd == "adcinvert") {
|
||||
if (action == PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1], "%x", &u32))
|
||||
;
|
||||
else
|
||||
return std::string("Could not scan adcinvert reg ") + std::string(args[1]);
|
||||
|
||||
myDet->setADCInvert(u32, detPos);
|
||||
}
|
||||
|
||||
os << std::hex << myDet->getADCInvert(detPos) << std::dec;
|
||||
|
||||
} else if (cmd == "extsamplingsrc") {
|
||||
if (action == PUT_ACTION) {
|
||||
|
||||
if (!sscanf(args[1], "%d", &addr))
|
||||
return std::string("Could not scan extsampling src ") + std::string(args[1]);
|
||||
|
||||
if (addr < 0 || addr > 63)
|
||||
return std::string("extsamplingsrc must be between 0 and 63. ") + std::string(args[1]);
|
||||
|
||||
myDet->setExternalSamplingSource(addr, detPos);
|
||||
}
|
||||
|
||||
os << myDet->getExternalSamplingSource(detPos);
|
||||
|
||||
} else if (cmd == "extsampling") {
|
||||
if (action == PUT_ACTION) {
|
||||
|
||||
if (!sscanf(args[1], "%d", &addr))
|
||||
return std::string("Could not scan extsampling enable ") + std::string(args[1]);
|
||||
|
||||
myDet->setExternalSampling(addr, detPos);
|
||||
}
|
||||
|
||||
os << myDet->getExternalSampling(detPos);
|
||||
|
||||
} else if (cmd == "rx_dbitlist") {
|
||||
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
std::vector <int> dbitlist;
|
||||
|
||||
// if not all digital bits enabled
|
||||
if (std::string(args[1]) != "all") {
|
||||
for (int i = 1; i < narg; ++i) {
|
||||
int temp = 0;
|
||||
if (!sscanf(args[i], "%d", &temp))
|
||||
return std::string("Could not scan dbitlist value ") +
|
||||
std::string(args[i]);
|
||||
if (temp < 0 || temp > 63)
|
||||
return std::string("dbitlist value should be between 0 and 63 ") +
|
||||
std::string(args[i]);
|
||||
dbitlist.push_back(temp);
|
||||
}
|
||||
if (dbitlist.size() > 64) {
|
||||
return std::string("Max number of values for dbitlist is 64 ");
|
||||
}
|
||||
}
|
||||
|
||||
myDet->setReceiverDbitList(dbitlist, detPos);
|
||||
}
|
||||
|
||||
std::vector <int> dbitlist = myDet->getReceiverDbitList(detPos);
|
||||
// all digital bits enabled
|
||||
if (dbitlist.empty())
|
||||
return std::string("all");
|
||||
// selective bits
|
||||
for (const auto &value : dbitlist)
|
||||
os << value << " ";
|
||||
|
||||
} else if (cmd == "rx_dbitoffset") {
|
||||
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
|
||||
if (!sscanf(args[1], "%d", &addr))
|
||||
return std::string("Could not scan rx_dbitoffset enable ") + std::string(args[1]);
|
||||
|
||||
myDet->setReceiverDbitOffset(addr, detPos);
|
||||
}
|
||||
|
||||
os << myDet->getReceiverDbitOffset(detPos);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
return helpPattern(action);
|
||||
|
Reference in New Issue
Block a user