From 83f2cf200bb84e683d99c86fba34b3ef9d9aa723 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Thu, 16 Jan 2014 22:21:36 +0200 Subject: [PATCH] data.c: Store cell count and system status into variable array Make it possible to reference this information via the variable array. This makes it possible to for example have the log file name to contain the number of battery cells and charger state. Signed-off-by: Timo Kokkonen --- data.c | 9 +++++++++ data.h | 1 + 2 files changed, 10 insertions(+) diff --git a/data.c b/data.c index 0db2394..c577a6e 100644 --- a/data.c +++ b/data.c @@ -123,6 +123,9 @@ static int parse_logline(const char *buf, struct charger_data *data) for (j = 0; j < max_cells; j++, i++) { d = atoi(entries[i]); ASSIGN_OR_NAN(data->cell_voltage[j], d / 1000.0); + + if (d) + data->cell_count++; } d = atoi(entries[i++]); @@ -325,6 +328,12 @@ static int read_data(struct eventhandler_entry *h) return 0; if (state_has_changed()) { + store_str_variable_value_to_array("status", + state_to_str(plotter_state.system_status), dt->cfg); + + store_int_variable_value_to_array("cell_count", + data.cell_count, dt->cfg); + ret = open_new_logfile(dt, data.channel); if (ret < 0) return ret; diff --git a/data.h b/data.h index b9c04c9..0906e4c 100644 --- a/data.h +++ b/data.h @@ -12,6 +12,7 @@ struct charger_data { double input_voltage; double charging_voltage; double charging_current; + int cell_count; double cell_voltage[MAX_CELLS]; double total_charge; /* mAh */ -- 2.44.0