|
RocketLogger
1.1.6
|
#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/mman.h>#include <sys/stat.h>#include <unistd.h>#include "rl_lib.h"#include "types.h"
Include dependency graph for rl_util.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | DEFAULT_CONFIG "/etc/rocketlogger/default.conf" |
| Default configuration file. More... | |
Typedefs | |
| typedef enum option | rl_option |
Enumerations | |
| enum | option { FILE_NAME, SAMPLE_RATE, UPDATE_RATE, CHANNEL, FHR, WEB, DIGITAL_INPUTS, AMBIENT, AGGREGATION, DEF_CONF, CALIBRATION, FILE_FORMAT, FILE_SIZE, COMMENT, NO_OPTION } |
Functions | |
| void | rl_print_config (struct rl_conf *conf) |
| void | rl_print_status (struct rl_status *status) |
| void | rl_print_version (void) |
| rl_mode | get_mode (char *mode) |
| rl_option | get_option (char *option) |
| int | parse_args (int argc, char *argv[], struct rl_conf *conf, int *set_as_default, char **file_comment) |
| void | print_usage (void) |
| void | print_config (struct rl_conf *conf) |
| void | reset_config (struct rl_conf *conf) |
| int | read_default_config (struct rl_conf *conf) |
| int | write_default_config (struct rl_conf *conf) |
| #define DEFAULT_CONFIG "/etc/rocketlogger/default.conf" |
Default configuration file.
Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition at line 48 of file rl_util.h.
Referenced by read_default_config(), and write_default_config().
| enum option |
Available options for RocketLogger CLI
| rl_mode get_mode | ( | char * | mode | ) |
Get RocketLogger mode of provided command line argument
| mode | Pointer to argument string to parse |
Definition at line 136 of file rl_util.c.
References CONTINUOUS, HELP, LIMIT, METER, NO_MODE, PRINT_DEFAULT, PRINT_VERSION, SET_DEFAULT, STATUS, and STOPPED.
Referenced by parse_args().
| rl_option get_option | ( | char * | option | ) |
Get RocketLogger option of provided command line argument
| option | Pointer to argument string to parse |
Definition at line 166 of file rl_util.c.
References AGGREGATION, AMBIENT, CALIBRATION, CHANNEL, COMMENT, DEF_CONF, DIGITAL_INPUTS, FHR, FILE_FORMAT, FILE_NAME, FILE_SIZE, NO_OPTION, SAMPLE_RATE, UPDATE_RATE, and WEB.
Referenced by parse_args().
| int parse_args | ( | int | argc, |
| char * | argv[], | ||
| struct rl_conf * | conf, | ||
| int * | set_as_default, | ||
| char ** | file_comment | ||
| ) |
Parse input arguments of RocketLogger CLI
| argc | Number of input arguments |
| argv | Input argument string |
| conf | Pointer to rl_conf configuration to write |
| set_as_default | Is set to 1, if configuration should be set as default |
| file_comment | Comment to write into the file header |
Definition at line 252 of file rl_util.c.
References AGGREGATE_AVERAGE, AGGREGATE_DOWNSAMPLE, AGGREGATE_NONE, AGGREGATION, rl_conf::aggregation, AMBIENT, rl_conf::ambient, AMBIENT_DISABLED, AMBIENT_ENABLED, ambient_set_file_name(), BIN, CAL_IGNORE, CAL_USE, CALIBRATION, rl_conf::calibration, CHANNEL, CHANNEL_ENABLED, rl_conf::channels, check_sample_rate(), check_update_rate(), COMMENT, CSV, DEF_CONF, DIGITAL_INPUTS, rl_conf::digital_inputs, DIGITAL_INPUTS_DISABLED, DIGITAL_INPUTS_ENABLED, rl_conf::enable_web_server, rl_ambient::enabled, ERROR, FAILURE, FHR, FILE_FORMAT, rl_conf::file_format, FILE_NAME, rl_conf::file_name, FILE_SIZE, rl_conf::force_high_channels, get_mode(), get_option(), HELP, INFO, KSPS, LIMIT, rl_conf::max_file_size, MAX_PATH_LENGTH, rl_conf::mode, NO_FILE, NO_MODE, NO_OPTION, parse_channels(), PRINT_DEFAULT, reset_config(), rl_log(), rl_conf::sample_limit, SAMPLE_RATE, rl_conf::sample_rate, SET_DEFAULT, STATUS, STOPPED, SUCCESS, UPDATE_RATE, rl_conf::update_rate, and WEB.
Referenced by main().
Here is the call graph for this function:| void print_config | ( | struct rl_conf * | conf | ) |
Print provided configuration to command line
| conf | Pointer to rl_conf configuration |
Definition at line 643 of file rl_util.c.
References rl_print_config().
Referenced by main().
Here is the call graph for this function:| void print_usage | ( | void | ) |
| int read_default_config | ( | struct rl_conf * | conf | ) |
Read default configuration from file
| conf | Pointer to rl_conf configuration |
Definition at line 683 of file rl_util.c.
References CONTINUOUS, DEFAULT_CONFIG, ERROR, FAILURE, rl_conf::mode, reset_config(), RL_CONF_VERSION, rl_log(), SUCCESS, UNDEFINED, rl_conf::version, and WARNING.
Referenced by main(), and print_status().
Here is the call graph for this function:| void reset_config | ( | struct rl_conf * | conf | ) |
Reset configuration to standard values
| conf | Pointer to rl_conf configuration |
Definition at line 653 of file rl_util.c.
References AGGREGATE_DOWNSAMPLE, rl_conf::aggregation, rl_conf::ambient, AMBIENT_DISABLED, BIN, CAL_USE, rl_conf::calibration, CHANNEL_ENABLED, rl_conf::channels, CONTINUOUS, rl_conf::digital_inputs, DIGITAL_INPUTS_ENABLED, rl_conf::enable_web_server, rl_ambient::enabled, rl_conf::file_format, rl_ambient::file_name, rl_conf::file_name, rl_conf::force_high_channels, rl_conf::max_file_size, rl_conf::mode, NUM_CHANNELS, RL_CONF_VERSION, rl_conf::sample_limit, rl_conf::sample_rate, rl_conf::update_rate, and rl_conf::version.
Referenced by parse_args(), and read_default_config().
| void rl_print_config | ( | struct rl_conf * | conf | ) |
Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Print RocketLogger configuration on command line
| conf | Pointer to rl_conf configuration |
Definition at line 40 of file rl_util.c.
References rl_conf::aggregation, CAL_IGNORE, rl_conf::calibration, CHANNEL_ENABLED, rl_conf::channels, rl_conf::digital_inputs, rl_conf::enable_web_server, rl_conf::file_format, rl_conf::file_name, rl_conf::force_high_channels, KSPS, rl_conf::max_file_size, NO_FILE, NUM_CHANNELS, NUM_I_CHANNELS, rl_conf::sample_limit, rl_conf::sample_rate, and rl_conf::update_rate.
Referenced by print_config(), and rl_print_status().
| void rl_print_status | ( | struct rl_status * | status | ) |
Print RocketLogger status on command line
| status | Pointer to rl_status status |
Definition at line 103 of file rl_util.c.
References rl_status::calibration_time, rl_status::conf, RL_OFF, rl_print_config(), rl_status::samples_taken, rl_status::state, and rl_calibration::time.
Referenced by main().
Here is the call graph for this function:| void rl_print_version | ( | void | ) |
Print the RocketLogger software version on the command line.
Definition at line 124 of file rl_util.c.
References COMPILE_DATE, GIT_DATE, GIT_DESCRIPTION, and PROJECT_VERSION.
Referenced by main().
| int write_default_config | ( | struct rl_conf * | conf | ) |