Skip to content
Snippets Groups Projects
Commit e74b42a8 authored by Dinyar Rabady's avatar Dinyar Rabady
Browse files

Quit more gracefully if configuration incomplete

Belongs to #15.
parent 680009a3
No related branches found
No related tags found
No related merge requests found
Pipeline #4532563 failed
......@@ -15,6 +15,10 @@ while true
do
echo "Starting scdaq..."
/opt/scdaq/bin/scdaq --config /etc/scdaq/scdaq.conf 2>&1 | logger --tag scdaq --id -p user.debug
if [[ $? == -1 ]]; then
echo "Unrecoverable error, won't retry."
exit 1
fi
echo "Resetting the board..."
../scripts/reset-firmware.sh
echo "Clearing caches..."
......
......@@ -45,5 +45,15 @@ void config::print()const {
for (std::map<std::string,std::string>::const_iterator it = vmap.begin(); it!=vmap.end(); it++){
LOG(INFO) << "key " << it->first << " value " << it->second;
}
}
bool config::validate() const {
bool valid { true };
for (std::map<std::string,std::string>::const_iterator it = vmap.begin(); it!=vmap.end(); it++){
if (it->second.empty()) {
valid &= false;
LOG(ERROR) << "Configuration entry " << it->first << " has no value!";
}
}
return valid;
}
......@@ -10,13 +10,15 @@
class config{
public:
enum class InputType { WZDMA, DMA, FILEDMA, MICRONDMA, FILE };
config(std::string filename);
void print() const;
bool validate() const;
InputType getInput() const {
const std::string& input = vmap.at("input");
if (input == "wzdma") {
......@@ -144,9 +146,9 @@ public:
return boost::lexical_cast<uint32_t>(v.c_str());
}
private:
std::map<std::string,std::string> vmap;
};
#endif
......@@ -147,6 +147,10 @@ if(argc < 2){
try {
config conf(argv[2]);
conf.print();
if (!conf.validate()) {
LOG(ERROR) << "Configuration invalid! Bailing out."
return -1;
}
LOG(DEBUG) << "Configuration loaded";
ctrl control;
// tbb::tick_count mainStartTime = tbb::tick_count::now();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment