diff --git a/scripts/run.sh b/scripts/run.sh index 7a2675d6e8fb1b27c4b3c0ff3afa576dbd230d64..856889aba8c0cab3fde1860e0e498cd96a9acc45 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -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..." diff --git a/src/config.cc b/src/config.cc index 5e3a1482f451fcc9c1194aeb3bd692545aeca7b9..5edb19b3bd203e39ffa6108ebb1292b0a9c84bad 100644 --- a/src/config.cc +++ b/src/config.cc @@ -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; } diff --git a/src/config.h b/src/config.h index e25680e5059012f9fb9711a88589ac29c0af1bbe..1430efdfadbd7235e96b90e97996ac8454f056c8 100644 --- a/src/config.h +++ b/src/config.h @@ -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 diff --git a/src/scdaq.cc b/src/scdaq.cc index 21f4c28a9d0b825c957131b43fbe52ef9e54f1f7..def393a136246488b4e07a3b6629a5a0c029c762 100644 --- a/src/scdaq.cc +++ b/src/scdaq.cc @@ -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();