diff --git a/.vscode/settings.json b/.vscode/settings.json index cad7657..bc273da 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "cmake.configureOnOpen": false + "cmake.configureOnOpen": false, + "C_Cpp.errorSquiggles": "disabled" } \ No newline at end of file diff --git a/utils/utils.c b/utils/utils.c index 8da4b58..1dde47b 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -156,10 +156,15 @@ int rw_params(int rw, int param_type, void * param_val) } if(param_type == PARAM_LIMITS) { + ((pump_limits_t *)param_val)->min_val = DEFAULT_PRES_MIN_LIMIT; + ((pump_limits_t *)param_val)->max_val = DEFAULT_PRES_MAX_LIMIT; + ((pump_limits_t *)param_val)->faultc = DEFAULT_PUMP_CURRENT_LIMIT; + ((pump_limits_t *)param_val)->stdev = DEFAULT_STDEV; + ((pump_limits_t *)param_val)->overp_lim = DEFAULT_OVERP_TIME_LIMIT; + ((pump_limits_t *)param_val)->void_run_count = DEFAULT_VOID_RUN_COUNT; if (stat(BASE_PATH"/"LIMITS_FILE, &st) != 0) { // file does no exists - ((pump_limits_t *)param_val)->min_val = ((pump_limits_t *)param_val)->max_val = ((pump_limits_t *)param_val)->faultc = ((pump_limits_t *)param_val)->stdev = 0; ret = ESP_OK; } else @@ -183,15 +188,15 @@ int rw_params(int rw, int param_type, void * param_val) if(fgets(buf, 64, f)) { ((pump_limits_t *)param_val)->overp_lim = atoi(buf); - ret = ESP_OK; + if(fgets(buf, 64, f)) + { + ((pump_limits_t *)param_val)->void_run_count = atoi(buf); + ret = ESP_OK; + } } } } } - else - { - ESP_LOGE(TAG, "max limit not found"); - } } else ESP_LOGI(TAG, "Limits file exists but its empty"); @@ -207,10 +212,10 @@ int rw_params(int rw, int param_type, void * param_val) } if(param_type == PARAM_OPERATIONAL) { + *(int *)param_val = PUMP_OFFLINE; if (stat(BASE_PATH"/"OPERATIONAL_FILE, &st) != 0) { // file does no exists - *(int *)param_val = PUMP_OFFLINE; ret = ESP_OK; } else @@ -218,7 +223,6 @@ int rw_params(int rw, int param_type, void * param_val) FILE *f = fopen(BASE_PATH"/"OPERATIONAL_FILE, "r"); if (f != NULL) { - *(int *)param_val = -1; if(fgets(buf, 64, f)) { *(int *)param_val = atoi(buf); @@ -314,9 +318,9 @@ int rw_params(int rw, int param_type, void * param_val) } else { - sprintf(buf, "%d\n%d\n%d\n%d\n%d\n", + sprintf(buf, "%d\n%d\n%d\n%d\n%d\n%d\n", ((pump_limits_t *)param_val)->min_val, ((pump_limits_t *)param_val)->max_val, ((pump_limits_t *)param_val)->faultc, - ((pump_limits_t *)param_val)->stdev, ((pump_limits_t *)param_val)->overp_lim); + ((pump_limits_t *)param_val)->stdev, ((pump_limits_t *)param_val)->overp_lim, ((pump_limits_t *)param_val)->void_run_count); if(fputs(buf, f) >= 0) ret = ESP_OK; fclose(f);