diff --git a/heater.cpp b/heater.cpp index cc5befb29a5020b77ba514edd81b21f105f1e148..bfef2fcd190ee44b668bdc48b48bdd3110fe7692 100644 --- a/heater.cpp +++ b/heater.cpp @@ -75,6 +75,8 @@ void Heaters::recoverDevice(int device) coincellhell_reset_bus(&devices[device].device); coincellhell_disconnect(&devices[device].device); ret = coincellhell_connect(&devices[device].device, devices[device].serial); + if(watchdogs) + coincellhell_enable_watchdog(&devices[device].device); } devices[device].mutex->unlock(); @@ -394,6 +396,7 @@ void Heaters::safetyCheck() void Heaters::enableWatchdogs() { + watchdogs = true; for(struct device& device : devices) { device.mutex->lock(); diff --git a/heaters.h b/heaters.h index c25bd146884bd056eeff38d2fa0e3cd108168586..a243d5513e33578b2fb553702d27de8ab62ad6fd 100644 --- a/heaters.h +++ b/heaters.h @@ -35,6 +35,7 @@ private: }; std::vector<struct device> devices; + bool watchdogs = false; std::function<void(int device, uint16_t serial, int code)> deviceFailCb; std::function<void(int heater, int device)> heaterFailCb; diff --git a/main.cpp b/main.cpp index fad22933d3bd8295ce9836e95a1c15c282e30604..c5c078415c152e169523559457aaf56d8dea200a 100644 --- a/main.cpp +++ b/main.cpp @@ -57,7 +57,7 @@ static void loggingThreadFn(Heaters* heaters, Multiplexers* multiplexers, static unsigned int step = 0; 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); if(!file.is_open()) @@ -105,7 +105,7 @@ static void loggingThreadFn(Heaters* heaters, Multiplexers* multiplexers, file<<temp<<','; } 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) return 2; } + if(config.watchdog) + { + Log(Log::INFO)<<"Enableing mcu watchdogs"; + heaters.enableWatchdogs(); + } + ret = expirament.run(config.globalStep, config.subStep); expirament.shutdown(); diff --git a/options.h b/options.h index 0f2648ae39f8ebefca852e1e1ce6478f34be37f2..7128b35a2257a92d31166f18b701ca34d03ced28 100644 --- a/options.h +++ b/options.h @@ -31,6 +31,7 @@ static struct argp_option options[] = {"sub-step", 'k', "[STEP NUMBER]", 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"}, + {"watchdog", 'w' , 0, 0, "enable mcu watchdogs"}, { 0 } }; @@ -50,6 +51,7 @@ struct Config size_t globalStep = 0; size_t subStep = 0; bool skipstart = false; + bool watchdog = false; }; 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) case 'z': config->skipstart = true; break; + case 'w': + config->watchdog = true; + break; default: return ARGP_ERR_UNKNOWN; }