Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #81 from lpetre-ulb/hotfix/ADCCachedRegistersObject
Browse files Browse the repository at this point in the history
Fixing DAC scans with cached registers for nOH != 0
  • Loading branch information
jsturdy authored Jan 28, 2019
2 parents c323274 + 87cc940 commit 78bfc74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
14 changes: 14 additions & 0 deletions include/lmdb_cpp_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,20 @@ class lmdb::dbi {
return lmdb::dbi_get(txn, handle(), key, data);
}

/**
* Retrieves a key from this database.
*
* @param txn a transaction handle
* @param key
* @throws lmdb::error on failure
*/
bool get(MDB_txn* const txn,
const std::string& key) const {
const lmdb::val k{key};
lmdb::val v{};
return lmdb::dbi_get(txn, handle(), k, v);
}

/**
* Retrieves a key from this database.
*
Expand Down
13 changes: 3 additions & 10 deletions src/calibration_routines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ std::vector<uint32_t> dacScanLocal(localArgs *la, uint32_t ohN, uint32_t dacSele
LOGGER->log_message(LogManager::INFO, stdsprintf("Scanning DAC: %s",regName.c_str()));
uint32_t adcAddr[24];
uint32_t adcCacheUpdateAddr[24];
bool foundAdcCached=false;
bool foundAdcCached = false;
for(int vfatN=0; vfatN<24; ++vfatN){
//Skip Masked VFATs
if ( !( (notmask >> vfatN) & 0x1)) continue;
Expand All @@ -1160,11 +1160,7 @@ std::vector<uint32_t> dacScanLocal(localArgs *la, uint32_t ohN, uint32_t dacSele
//Get ADC address
if(useExtRefADC){ //Case: Use ADC with external reference
//for backward compatibility, use ADC1 instead of ADC1_CACHED if it exists
lmdb::val key, db_res;

key.assign(strRegBase+"ADC1_CACHED");
foundAdcCached = la->dbi.get(la->rtxn,key,db_res);
if(foundAdcCached){
if((foundAdcCached = la->dbi.get(la->rtxn, strRegBase + "ADC1_CACHED"))){
adcAddr[vfatN] = getAddress(la, strRegBase + "ADC1_CACHED");
adcCacheUpdateAddr[vfatN] = getAddress(la, strRegBase + "ADC1_UPDATE");
}
Expand All @@ -1173,10 +1169,7 @@ std::vector<uint32_t> dacScanLocal(localArgs *la, uint32_t ohN, uint32_t dacSele
} //End Case: Use ADC with external reference
else{ //Case: Use ADC with internal reference
//for backward compatibility, use ADC0 instead of ADC0_CACHED if it exists
lmdb::val key, db_res;
key.assign(strRegBase+"ADC0_CACHED");
foundAdcCached = la->dbi.get(la->rtxn,key,db_res);
if(foundAdcCached) {
if((foundAdcCached = la->dbi.get(la->rtxn, strRegBase + "ADC0_CACHED"))){
adcAddr[vfatN] = getAddress(la, strRegBase + "ADC0_CACHED");
adcCacheUpdateAddr[vfatN] = getAddress(la, strRegBase + "ADC0_UPDATE");
}
Expand Down

0 comments on commit 78bfc74

Please sign in to comment.