]> git.itanic.dy.fi Git - log-plotter/log
log-plotter
10 years agodata.c: Reset time stamp when starting new log master
Timo Kokkonen [Fri, 28 Feb 2014 19:16:04 +0000 (21:16 +0200)]
data.c: Reset time stamp when starting new log

Whenever we start logging a new charging session, start counting the
time from zero.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agodata.c: Store cell count and system status into variable array
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>
10 years agoconfig.c: Export store_str_variable_value_to_array()
Timo Kokkonen [Thu, 16 Jan 2014 20:20:07 +0000 (22:20 +0200)]
config.c: Export store_str_variable_value_to_array()

Make it possible to store string values into array database even from
outside of config.c.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agomain.c: Add missing endline to debug print
Timo Kokkonen [Thu, 16 Jan 2014 20:14:31 +0000 (22:14 +0200)]
main.c: Add missing endline to debug print

Avoid cluttering the debug output with unterminated lines..

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoconfig.c: Handle multiple variables correcly
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>
10 years agodata.c: Implement initial support for handling multiple data channels
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>
10 years agoconfig.c: Implement store_int_variable_value_to_array()
Timo Kokkonen [Sun, 29 Dec 2013 15:10:55 +0000 (17:10 +0200)]
config.c: Implement store_int_variable_value_to_array()

This can be used to insert variable entries with integer type into the
variable array.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoconfig.c: Add support for replacing variables names from strings
Timo Kokkonen [Sun, 29 Dec 2013 11:41:37 +0000 (13:41 +0200)]
config.c: Add support for replacing variables names from strings

Read all unknown config options from the config file and store them in
the config variable array.

Implement a new function that can be used to replace variable names
from a string with the contents of the variable name in question.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agobal.plot: Convert volts to millivolts correctly
Timo Kokkonen [Sat, 28 Dec 2013 20:06:34 +0000 (22:06 +0200)]
bal.plot: Convert volts to millivolts correctly

The multiplier was wrong. This mistake was apparently a leftover from
the older scripts that interpreted the iCharger data directly.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoUse the same config structure for command line and config file
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>
10 years agoprint_status_line: Print textual status
Timo Kokkonen [Sun, 3 Nov 2013 20:17:39 +0000 (22:17 +0200)]
print_status_line: Print textual status

Now that we know which status we are in, print it in the textual form.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoImplement state machine based architecture
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>
10 years agodata.c: Reduce excess debug verbosity
Timo Kokkonen [Sun, 3 Nov 2013 19:55:24 +0000 (21:55 +0200)]
data.c: Reduce excess debug verbosity

We trust now that the data parsing works. No need to print that many
lines of debug print.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoConvert data reading into event based system
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>
10 years agoMove random utility macros into utils.h
Timo Kokkonen [Tue, 29 Oct 2013 20:15:15 +0000 (22:15 +0200)]
Move random utility macros into utils.h

Avoid defining useful utility macros in C files.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd primitive config file parsing support
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>
10 years agoRename debug.[ch] to trace.[ch]
Timo Kokkonen [Sun, 20 Oct 2013 11:56:43 +0000 (14:56 +0300)]
Rename debug.[ch] to trace.[ch]

This file is more about tracing than debugging, Rename it to match
more what it really is about.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agodata.h: Fix comment
Timo Kokkonen [Mon, 14 Oct 2013 18:53:04 +0000 (21:53 +0300)]
data.h: Fix comment

The temperature is not in millivolts, is is just plain volts. Fix the
comment appropriately.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd charging current and total charge into the status field
Timo Kokkonen [Mon, 14 Oct 2013 18:51:43 +0000 (21:51 +0300)]
Add charging current and total charge into the status field

These are useful pieces of information for the curious user.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoplotter scripts: Add automatic x-axis tick scaling
Tero Salminen [Sat, 12 Oct 2013 19:53:27 +0000 (22:53 +0300)]
plotter scripts: Add automatic x-axis tick scaling

Change the x-tics based on the maximum timestamp. This makes the plot
graphs look better when they are being re-plotter real time during
charging.

Signed-off-by: Tero Salminen <tero.s@lminen.com>
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd nice html pages for real time charging view
Tero Salminen [Sat, 12 Oct 2013 19:36:35 +0000 (22:36 +0300)]
Add nice html pages for real time charging view

With these html files it is possible to use web browser to see a real
time view of the actual charging process.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
10 years agoAdd improved gnuplot scripts
Tero Salminen [Fri, 11 Oct 2013 15:05:06 +0000 (18:05 +0300)]
Add improved gnuplot scripts

Replace the old and ugly plotter scripts with all new and shiny
scripts that produce nice beautiful plots.

Signed-off-by: Tero Salminen <tero.s@lminen.com>
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
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>