]> git.itanic.dy.fi Git - log-plotter/log
log-plotter
10 years agodata: Print fancy status line
Timo Kokkonen [Thu, 10 Oct 2013 18:58:53 +0000 (21:58 +0300)]
data: Print fancy status line

Replace the raw dump of the input data with a better status line. This
has got a human readable values of some relevant data inputs.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agodata: Move the total charge field at the end of the data
Timo Kokkonen [Thu, 10 Oct 2013 18:33:44 +0000 (21:33 +0300)]
data: Move the total charge field at the end of the data

The agreed log format has mAh at the end, so this needs to be moved
there in order to comply to the agreed format.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoFill in time stamp even if charger produces zero input
Timo Kokkonen [Thu, 10 Oct 2013 18:32:45 +0000 (21:32 +0300)]
Fill in time stamp even if charger produces zero input

Always zero timestamp is invalid. Replace it with a proper one.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agodata.c: Add data parsing and output processing
Timo Kokkonen [Wed, 9 Oct 2013 19:49:27 +0000 (22:49 +0300)]
data.c: Add data parsing and output processing

Parse all input data into C structure. This allows proper processing
of the data.

Print out the data into the log file in proper format after the processing.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agorefactor data handling into data.c
Timo Kokkonen [Tue, 8 Oct 2013 18:55:31 +0000 (21:55 +0300)]
refactor data handling into data.c

Let's keep main.c clean and make new file for data handling.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years ago.gitignore: Prevent junk being visible to git
Timo Kokkonen [Tue, 8 Oct 2013 18:38:13 +0000 (21:38 +0300)]
.gitignore: Prevent junk being visible to git

There is likely to be a lot of log files, png images and other stuff
that we are not interested in seeing in git. Hide them.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd missing initialization
Timo Kokkonen [Mon, 7 Oct 2013 18:23:43 +0000 (21:23 +0300)]
Add missing initialization

We are passing on the variable to read_log_line() function and it
needs to be initialized properly prior the first use.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoMove time stamp initialization after first proper log entry is read
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>
10 years agoDiscard too short log lines
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>
10 years agoFix another incorrect test against read() return value
Timo Kokkonen [Mon, 7 Oct 2013 18:05:40 +0000 (21:05 +0300)]
Fix another incorrect test against read() return value

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd timestamp to the output data.
Timo Kokkonen [Mon, 7 Oct 2013 17:58:23 +0000 (20:58 +0300)]
Add timestamp to the output data.

Proper timestamps are required in order to print time on the X axis of
the output graphs.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agooptions: Add help
Timo Kokkonen [Mon, 7 Oct 2013 17:36:53 +0000 (20:36 +0300)]
options: Add help

Keep the users happy by letting them know how to use this damn thing.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agooptions: Fix short option for --baud
Timo Kokkonen [Mon, 7 Oct 2013 14:58:38 +0000 (17:58 +0300)]
options: Fix short option for --baud

--baud in short is -b

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agooptions: Make trace level adjustable
Timo Kokkonen [Mon, 7 Oct 2013 14:38:01 +0000 (17:38 +0300)]
options: Make trace level adjustable

We already have a TRACE_DEBUG level but we can't show up the prints
there unless we are able to adjust the trace level too. Now we can.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoFix read return value check
Timo Kokkonen [Sun, 6 Oct 2013 19:58:07 +0000 (22:58 +0300)]
Fix read return value check

We wish to check against the return value of read, not the function
pointer..

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoread_data: Handle the input data more gracefully
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>
10 years agomain: Refactor data reading out from main
Timo Kokkonen [Sun, 6 Oct 2013 18:39:45 +0000 (21:39 +0300)]
main: Refactor data reading out from main

Keep the main function simple. Factor out all irrelevant data
processing.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agomain: Open ouput file when one is requested
Timo Kokkonen [Sun, 6 Oct 2013 15:26:14 +0000 (18:26 +0300)]
main: Open ouput file when one is requested

Write the read data into a given logfile and not only into stdout.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoConvert all existing prints into appropriate trace print
Timo Kokkonen [Sun, 6 Oct 2013 14:58:10 +0000 (17:58 +0300)]
Convert all existing prints into appropriate trace print

Don't use printf for trace messages as we have the new tracing code.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd more advanced debug macro
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>
10 years agoAdd command line parsing
Timo Kokkonen [Sun, 6 Oct 2013 13:46:58 +0000 (16:46 +0300)]
Add command line parsing

Add generic commnd line parsing code for adjusting the run time
configurable parameters.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agobaud: Add missing newline to error print
Timo Kokkonen [Sun, 6 Oct 2013 13:42:07 +0000 (16:42 +0300)]
baud: Add missing newline to error print

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd draw_plots.sh
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>
10 years agomain: Add missing EOF check to serial read
Timo Kokkonen [Fri, 4 Oct 2013 19:52:33 +0000 (22:52 +0300)]
main: Add missing EOF check to serial read

If we got EOF from the serial port, close it and exit. Nothing more to
do.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agomain: Fix busy loop with reading
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>
10 years agoAdd couple of example gnuplot files for plotting graphs
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>
10 years agoInitial commit
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>