Timo Kokkonen [Thu, 16 Jan 2014 20:21:36 +0000 (22:21 +0200)]
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 <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Thu, 16 Jan 2014 20:11:47 +0000 (22:11 +0200)]
config.c: Handle multiple variables correcly
If we happen to have multiple variables in the string we are handling,
we must continue handling the string always at the end of the previous
replaced variable. Otherwise we may end up skipping the beginning of
the next variable.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sun, 29 Dec 2013 15:15:33 +0000 (17:15 +0200)]
data.c: Implement initial support for handling multiple data channels
This initial implementation will simply open a separate log file for
every data channel. User can refer to the channel name with $(channel)
variable in the file name.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sat, 9 Nov 2013 11:50:24 +0000 (13:50 +0200)]
Use the same config structure for command line and config file
We have now two redundant structures that hold the configuration data
for log-plotter. Remove the redundant one and use only one structure
for holding all configuration data.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sun, 3 Nov 2013 20:11:39 +0000 (22:11 +0200)]
Implement state machine based architecture
The main loop is now at the main function, where we control all of the
actual functions of the program, and really do nothing. All other
functions happen elsewhere and are being called only when interesting
events occur.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Thu, 31 Oct 2013 19:22:45 +0000 (21:22 +0200)]
Convert data reading into event based system
As of preparing for the future, convert the data reading into an even
based system. The main loop has got the loop that holds the state of
the logging process. All other modules then register itself into the
event system where they get called back whenever data gets feed in
into their file descriptors.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Tue, 29 Oct 2013 19:41:26 +0000 (21:41 +0200)]
Add primitive config file parsing support
This supports parsing "variable = value" style lines from a config
file. The file can also have blank lines and comments starting with
'#' character. Anything it doesn't understand are skipped.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Mon, 7 Oct 2013 18:11:41 +0000 (21:11 +0300)]
Move time stamp initialization after first proper log entry is read
If we initialize the time stamp too early, the first log entry that we
read will not have zero as its timestamp. Move the initialization
after we know the data is valid to avoid the problem.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Mon, 7 Oct 2013 18:08:56 +0000 (21:08 +0300)]
Discard too short log lines
Some times the serial output contains incorrect entries, typically in
the beginning of log acquicition. Discard them so that they don't
clutter the log output.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sun, 6 Oct 2013 19:25:04 +0000 (22:25 +0300)]
read_data: Handle the input data more gracefully
The serial port is giving the data to us very slowly, perhaps only a
few bytes a time. Therefore we need to take special care in order to
not handle incomplete log lines.
Add a new function to read one complete line of data from the
device. Once the complete line is read, write it to the logfile (if
one is open) and then also to the console.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sun, 6 Oct 2013 14:57:09 +0000 (17:57 +0300)]
Add more advanced debug macro
Make it possible to have multiple debug levels. This makes it possible
to remove unneeded (debug) output when user is not interested in
seeing the output.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sat, 5 Oct 2013 19:20:33 +0000 (22:20 +0300)]
Add draw_plots.sh
This simple helper script draws all plots for a given logfile. The
.plot files are adjusted to not use a fixed file name, but instead
rely on the calling script to set the file into "datafile" variable.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Mon, 30 Sep 2013 18:09:07 +0000 (21:09 +0300)]
main: Fix busy loop with reading
As the baud.c opens the serial device with O_NBLOCK flag, read will
just return immediately when there is nothing to read. That basically
makes the read loop a a busy loop, consuming one CPU core fully at all
times.
Fix the problem by using epoll to wait until something becomes
available on the serial port to read.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sun, 29 Sep 2013 19:30:52 +0000 (22:30 +0300)]
Add couple of example gnuplot files for plotting graphs
voltage_and_current.plot: This one plots somewhat typical charging
graphs with voltage, current and accumulated charge visible.
balancing.plot: This one plots a graph of the balancing action. Cell
voltages compared to the average cell voltages (over average of five
samples) is plotted.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Timo Kokkonen [Sun, 29 Sep 2013 19:05:52 +0000 (22:05 +0300)]
Initial commit
Add a very very simple version of the "plotter". It does no plotting,
it only opens the serial device with correct baud rate, reads out the
data at correct baud rate (correct for an iCharger 206B charer) and
prints out exactly what it read. Dumb as hell but works.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>