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

Quit more gracefully if configuration incomplete

Belongs to #15.
parent 2e5b9081
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ enable_stream_processor:yes ...@@ -59,7 +59,7 @@ enable_stream_processor:yes
# Note: When changing the processing type, change also "output_filename_prefix" # Note: When changing the processing type, change also "output_filename_prefix"
# in the file output section. # in the file output section.
# #
#processor_type:GMT processor_type:
# Enable software zero-supression # Enable software zero-supression
doZS:yes doZS:yes
...@@ -70,9 +70,9 @@ doZS:yes ...@@ -70,9 +70,9 @@ doZS:yes
## ##
################################################################################ ################################################################################
#output_filename_prefix:scout_GMT output_filename_prefix:
#output_filename_base:/fff/BU0/ramdisk/scdaq output_filename_base:
max_file_size:8589934592 max_file_size:8589934592
......
...@@ -15,6 +15,10 @@ while true ...@@ -15,6 +15,10 @@ while true
do do
echo "Starting scdaq..." echo "Starting scdaq..."
/opt/scdaq/bin/scdaq --config /etc/scdaq/scdaq.conf 2>&1 /opt/scdaq/bin/scdaq --config /etc/scdaq/scdaq.conf 2>&1
if [[ ${PIPESTATUS[0]} == 78 ]]; then # Numerical value of EX_CONFIG.
# If the configuration is incomplete there's no point in us retrying forever..
exit 1
fi
echo "Resetting the board..." echo "Resetting the board..."
../scripts/reset-firmware.sh ../scripts/reset-firmware.sh
echo "Clearing caches..." echo "Clearing caches..."
......
...@@ -31,12 +31,15 @@ config::config(std::string filename){ ...@@ -31,12 +31,15 @@ config::config(std::string filename){
std::string key = line.substr(0, delim); std::string key = line.substr(0, delim);
std::string value = line.substr(delim + 1); std::string value = line.substr(delim + 1);
if (key.empty() || value.empty()) { if (key.empty()) {
// Skip ill formated lines // Skip ill formated lines
continue; continue;
} }
//std::cout << "key: " << key << ", value: " << value << "\n"; if (value.empty()) {
LOG(ERROR) << "Configuration entry " << key << " has no value!";
valid_ &= false;
}
vmap[key] = value; vmap[key] = value;
} }
...@@ -45,5 +48,8 @@ void config::print()const { ...@@ -45,5 +48,8 @@ void config::print()const {
for (std::map<std::string,std::string>::const_iterator it = vmap.begin(); it!=vmap.end(); it++){ for (std::map<std::string,std::string>::const_iterator it = vmap.begin(); it!=vmap.end(); it++){
LOG(INFO) << "key " << it->first << " value " << it->second; LOG(INFO) << "key " << it->first << " value " << it->second;
} }
}
bool config::valid() const {
return valid_;
} }
...@@ -10,13 +10,15 @@ ...@@ -10,13 +10,15 @@
class config{ class config{
public: public:
enum class InputType { WZDMA, DMA, FILEDMA, MICRONDMA, FILE }; enum class InputType { WZDMA, DMA, FILEDMA, MICRONDMA, FILE };
config(std::string filename); config(std::string filename);
void print() const; void print() const;
bool valid() const;
InputType getInput() const { InputType getInput() const {
const std::string& input = vmap.at("input"); const std::string& input = vmap.at("input");
if (input == "wzdma") { if (input == "wzdma") {
...@@ -144,9 +146,10 @@ public: ...@@ -144,9 +146,10 @@ public:
return boost::lexical_cast<uint32_t>(v.c_str()); return boost::lexical_cast<uint32_t>(v.c_str());
} }
private: private:
std::map<std::string,std::string> vmap; std::map<std::string,std::string> vmap;
bool valid_ = true;
}; };
#endif #endif
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <cctype> #include <cctype>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <sysexits.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
...@@ -147,6 +148,10 @@ if(argc < 2){ ...@@ -147,6 +148,10 @@ if(argc < 2){
try { try {
config conf(argv[2]); config conf(argv[2]);
conf.print(); conf.print();
if (!conf.valid()) {
LOG(ERROR) << "Configuration invalid! Bailing out.";
return EX_CONFIG;
}
LOG(DEBUG) << "Configuration loaded"; LOG(DEBUG) << "Configuration loaded";
ctrl control; ctrl control;
// tbb::tick_count mainStartTime = tbb::tick_count::now(); // 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