cl
2014-09-30 11:35:01 UTC
I am developing some code which runs on a (remote from me most of the
time) Beaglebone Black single board computer. It reads various items
of data (voltages, currents, temperatures, etc.) using both a 1-wire
bus system and the Beaglebone's ADC inputs. The values are stored
at hourly intervals into a database which is regularly rsync'ed
across to my home system where I use the values for monitoring etc.
Associated with each value are various parameters, i.e. for each ADC
input of the Beaglebone there is the ADC input number, a short name
for the value, a conversion factor and a description. Similarly for
the 1-wire inputs there is the 1-wire filesystem filename, a short
name for the data and a longer description.
I am puzzling where and how to keep these configuration values. My
current design has them in dedicated tables in the database but this
is rather clumsy in many ways as there's an overhead reading them
every time the program needs them and changing them isn't particularly
convenient at the Beaglebone doesn't have a GUI so it has to be done
using SQL from the command line.
Does it make sense to add them to the modules which handle the reading
of the inputs? I already have modules defining classes called Adc and
OneWire, is it a reasonable approach to add the configuration to these
as, probably, dictionaries? Modifying it would be pretty simple -
just edit the python source (one of the easiest things for me to do on
the Beaglebone as my sole access is via ssh/command line).
Thus I'd have something like (apologies for any syntax errors):-
cfg = { "LeisureVolts": ["AIN0", 0.061256, "Leisure Battery Voltage"],
"StarterVolts": ["AIN1", 0.060943, "Starter Battery Voltage"],
"LeisureAmps1": ["AIN2", 0.423122, "Leisure Battery Current"}
(It might be better to makes those lists dictionaries, but it shows
the idea)
Are there any better ways of doing this? E.g. some sort of standard
configuration file format that Python knows about? I would actually
quite like to keep the configuration data separate from the code as it
would simplify using the data at the 'home' end of things as I'd just
need to copy the configuration file across. This was why the database
approach appealed at first as all I need to do is copy the database
and everything is in there.
I'm not really expecting quick/glib answers, just some ideas and
comments on the various ways of doing this and their advantages and
disadvantages.
time) Beaglebone Black single board computer. It reads various items
of data (voltages, currents, temperatures, etc.) using both a 1-wire
bus system and the Beaglebone's ADC inputs. The values are stored
at hourly intervals into a database which is regularly rsync'ed
across to my home system where I use the values for monitoring etc.
Associated with each value are various parameters, i.e. for each ADC
input of the Beaglebone there is the ADC input number, a short name
for the value, a conversion factor and a description. Similarly for
the 1-wire inputs there is the 1-wire filesystem filename, a short
name for the data and a longer description.
I am puzzling where and how to keep these configuration values. My
current design has them in dedicated tables in the database but this
is rather clumsy in many ways as there's an overhead reading them
every time the program needs them and changing them isn't particularly
convenient at the Beaglebone doesn't have a GUI so it has to be done
using SQL from the command line.
Does it make sense to add them to the modules which handle the reading
of the inputs? I already have modules defining classes called Adc and
OneWire, is it a reasonable approach to add the configuration to these
as, probably, dictionaries? Modifying it would be pretty simple -
just edit the python source (one of the easiest things for me to do on
the Beaglebone as my sole access is via ssh/command line).
Thus I'd have something like (apologies for any syntax errors):-
cfg = { "LeisureVolts": ["AIN0", 0.061256, "Leisure Battery Voltage"],
"StarterVolts": ["AIN1", 0.060943, "Starter Battery Voltage"],
"LeisureAmps1": ["AIN2", 0.423122, "Leisure Battery Current"}
(It might be better to makes those lists dictionaries, but it shows
the idea)
Are there any better ways of doing this? E.g. some sort of standard
configuration file format that Python knows about? I would actually
quite like to keep the configuration data separate from the code as it
would simplify using the data at the 'home' end of things as I'd just
need to copy the configuration file across. This was why the database
approach appealed at first as all I need to do is copy the database
and everything is in there.
I'm not really expecting quick/glib answers, just some ideas and
comments on the various ways of doing this and their advantages and
disadvantages.
--
Chris Green
?
Chris Green
?