Skip to content
Snippets Groups Projects
Commit 8f11bbd8 authored by Carl Philipp Klemm's avatar Carl Philipp Klemm
Browse files

add mcu watchdog support

parent 0c4bafd4
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,8 @@ void Heaters::recoverDevice(int device) ...@@ -75,6 +75,8 @@ void Heaters::recoverDevice(int device)
coincellhell_reset_bus(&devices[device].device); coincellhell_reset_bus(&devices[device].device);
coincellhell_disconnect(&devices[device].device); coincellhell_disconnect(&devices[device].device);
ret = coincellhell_connect(&devices[device].device, devices[device].serial); ret = coincellhell_connect(&devices[device].device, devices[device].serial);
if(watchdogs)
coincellhell_enable_watchdog(&devices[device].device);
} }
devices[device].mutex->unlock(); devices[device].mutex->unlock();
...@@ -394,6 +396,7 @@ void Heaters::safetyCheck() ...@@ -394,6 +396,7 @@ void Heaters::safetyCheck()
void Heaters::enableWatchdogs() void Heaters::enableWatchdogs()
{ {
watchdogs = true;
for(struct device& device : devices) for(struct device& device : devices)
{ {
device.mutex->lock(); device.mutex->lock();
......
...@@ -35,6 +35,7 @@ private: ...@@ -35,6 +35,7 @@ private:
}; };
std::vector<struct device> devices; std::vector<struct device> devices;
bool watchdogs = false;
std::function<void(int device, uint16_t serial, int code)> deviceFailCb; std::function<void(int device, uint16_t serial, int code)> deviceFailCb;
std::function<void(int heater, int device)> heaterFailCb; std::function<void(int heater, int device)> heaterFailCb;
......
...@@ -57,7 +57,7 @@ static void loggingThreadFn(Heaters* heaters, Multiplexers* multiplexers, ...@@ -57,7 +57,7 @@ static void loggingThreadFn(Heaters* heaters, Multiplexers* multiplexers,
static unsigned int step = 0; static unsigned int step = 0;
Log(Log::INFO)<<"Logging thread has started"; Log(Log::INFO)<<"Logging thread has started";
std::filesystem::path logfile = outdir/"expiramentlog.txt"; std::filesystem::path logfile = outdir/"expiramentlog.csv";
std::fstream file(logfile, std::ios_base::out); std::fstream file(logfile, std::ios_base::out);
if(!file.is_open()) if(!file.is_open())
...@@ -105,7 +105,7 @@ static void loggingThreadFn(Heaters* heaters, Multiplexers* multiplexers, ...@@ -105,7 +105,7 @@ static void loggingThreadFn(Heaters* heaters, Multiplexers* multiplexers,
file<<temp<<','; file<<temp<<',';
} }
file<<std::endl; file<<std::endl;
std::this_thread::sleep_for(std::chrono::seconds(5)); std::this_thread::sleep_for(std::chrono::seconds(10));
} }
} }
...@@ -252,6 +252,12 @@ int main(int argc, char** argv) ...@@ -252,6 +252,12 @@ int main(int argc, char** argv)
return 2; return 2;
} }
if(config.watchdog)
{
Log(Log::INFO)<<"Enableing mcu watchdogs";
heaters.enableWatchdogs();
}
ret = expirament.run(config.globalStep, config.subStep); ret = expirament.run(config.globalStep, config.subStep);
expirament.shutdown(); expirament.shutdown();
......
...@@ -31,6 +31,7 @@ static struct argp_option options[] = ...@@ -31,6 +31,7 @@ static struct argp_option options[] =
{"sub-step", 'k', "[STEP NUMBER]", 0, "sets the subset of the expirament"}, {"sub-step", 'k', "[STEP NUMBER]", 0, "sets the subset of the expirament"},
{"stepfile", 'f', "[PATH]", 0, "sets the subset of the expirament"}, {"stepfile", 'f', "[PATH]", 0, "sets the subset of the expirament"},
{"skip-start", 'z' , 0, 0, "skipps the startup sequence"}, {"skip-start", 'z' , 0, 0, "skipps the startup sequence"},
{"watchdog", 'w' , 0, 0, "enable mcu watchdogs"},
{ 0 } { 0 }
}; };
...@@ -50,6 +51,7 @@ struct Config ...@@ -50,6 +51,7 @@ struct Config
size_t globalStep = 0; size_t globalStep = 0;
size_t subStep = 0; size_t subStep = 0;
bool skipstart = false; bool skipstart = false;
bool watchdog = false;
}; };
static std::vector<uint16_t> parseList(const std::string& in) static std::vector<uint16_t> parseList(const std::string& in)
...@@ -116,6 +118,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) ...@@ -116,6 +118,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case 'z': case 'z':
config->skipstart = true; config->skipstart = true;
break; break;
case 'w':
config->watchdog = true;
break;
default: default:
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment