|
RocketLogger
2.0.0
|
#include <errno.h>#include <stdarg.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include <sys/ipc.h>#include <sys/shm.h>#include <sys/types.h>#include <unistd.h>#include <zmq.h>#include "log.h"#include "sensor/sensor.h"#include "rl.h"
Include dependency graph for rl.c:Go to the source code of this file.
Macros | |
| #define | RL_JSON_BUFFER_SIZE 10000 |
Functions | |
| void | rl_config_print (rl_config_t const *const config) |
| void | rl_config_print_cmd (rl_config_t const *const config) |
| void | rl_config_print_json (rl_config_t const *const config) |
| char * | rl_config_get_json (rl_config_t const *const config) |
| void | rl_config_reset (rl_config_t *const config) |
| int | rl_config_read_default (rl_config_t *const config) |
| int | rl_config_write_default (rl_config_t const *const config) |
| int | rl_config_validate (rl_config_t const *const config) |
| pid_t | rl_pid_get (void) |
| int | rl_pid_set (pid_t pid) |
| void | rl_status_reset (rl_status_t *const status) |
| int | rl_status_pub_init (void) |
| int | rl_status_pub_deinit (void) |
| int | rl_status_shm_init (void) |
| int | rl_status_shm_deinit (void) |
| int | rl_status_read (rl_status_t *const status) |
| int | rl_status_write (rl_status_t *const status) |
| void | rl_status_print (rl_status_t const *const status) |
| void | rl_status_print_json (rl_status_t const *const status) |
| char * | rl_status_get_json (rl_status_t const *const status) |
Variables | |
| const rl_config_t | rl_config_default |
| const rl_status_t | rl_status_default |
| char const *const | RL_CHANNEL_NAMES [RL_CHANNEL_COUNT] |
| RocketLogger channel names. More... | |
| char const *const | RL_CHANNEL_FORCE_NAMES [RL_CHANNEL_SWITCHED_COUNT] |
| RocketLogger force range channel names. More... | |
| char const *const | RL_CHANNEL_DIGITAL_NAMES [RL_CHANNEL_DIGITAL_COUNT] |
| RocketLogger digital channel names. More... | |
| char const *const | RL_CHANNEL_VALID_NAMES [RL_CHANNEL_SWITCHED_COUNT] |
| RocketLogger valid channel names. More... | |
| rl_status_t | rl_status |
| Global RocketLogger status variable. More... | |
| void * | zmq_status_context = NULL |
| The ZeroMQ context for status publishing. More... | |
| void * | zmq_status_publisher = NULL |
| The ZeroMQ status publisher. More... | |
| char* rl_config_get_json | ( | rl_config_t const *const | config | ) |
Get RocketLogger configuration as JSON data structure string.
| config | The measurement configuration |
Definition at line 280 of file rl.c.
References rl_config::ambient_enable, rl_config::background_enable, rl_config::calibration_ignore, rl_config::channel_enable, rl_config::channel_force_range, rl_config::digital_enable, rl_config::file_comment, rl_config::file_enable, rl_config::file_format, rl_config::file_name, rl_config::file_size, rl_config::interactive_enable, RL_CHANNEL_COUNT, RL_CHANNEL_FORCE_NAMES, RL_CHANNEL_NAMES, RL_CHANNEL_SWITCHED_COUNT, RL_FILE_FORMAT_CSV, RL_FILE_FORMAT_RLD, RL_JSON_BUFFER_SIZE, rl_config::sample_limit, rl_config::sample_rate, snprintfcat(), rl_config::update_rate, and rl_config::web_enable.
Referenced by rl_config_print_json(), and rl_status_get_json().
Here is the call graph for this function:| void rl_config_print | ( | rl_config_t const *const | config | ) |
| void rl_config_print_cmd | ( | rl_config_t const *const | config | ) |
Print RocketLogger command line string correpsinding to the current configuration.
| config | The measurement configuration to print |
Definition at line 211 of file rl.c.
References rl_config::aggregation_mode, rl_config::ambient_enable, rl_config::background_enable, rl_config::calibration_ignore, rl_config::channel_enable, rl_config::channel_force_range, rl_config::digital_enable, rl_config::file_comment, rl_config::file_enable, rl_config::file_format, rl_config::file_name, rl_config::file_size, rl_config::interactive_enable, RL_AGGREGATION_MODE_AVERAGE, RL_AGGREGATION_MODE_DOWNSAMPLE, RL_CHANNEL_COUNT, RL_CHANNEL_FORCE_NAMES, RL_CHANNEL_NAMES, RL_CHANNEL_SWITCHED_COUNT, RL_FILE_FORMAT_RLD, rl_config::sample_limit, rl_config::sample_rate, rl_config::update_rate, and rl_config::web_enable.
| void rl_config_print_json | ( | rl_config_t const *const | config | ) |
Print RocketLogger configuration as JSON data structure.
| config | The measurement configuration to print |
Definition at line 275 of file rl.c.
References rl_config_get_json().
Here is the call graph for this function:| int rl_config_read_default | ( | rl_config_t *const | config | ) |
Read default configuration from file.
Try to read user configuration otherwis fallback to system configuration.
| config | The measurement configuration structure to store the default to |
Definition at line 364 of file rl.c.
References rl_config::config_version, ERROR, rl_config::file_comment, RL_CONFIG_COMMENT_DEFAULT, rl_config_reset(), RL_CONFIG_SYSTEM_FILE, RL_CONFIG_USER_FILE, RL_CONFIG_VERSION, rl_log(), RL_LOG_ERROR, RL_LOG_WARNING, and SUCCESS.
Referenced by main().
Here is the call graph for this function:| void rl_config_reset | ( | rl_config_t *const | config | ) |
Reset configuration to standard values.
| config | The measurement configuration to reset |
Definition at line 360 of file rl.c.
References rl_config_default.
Referenced by adc_calibrate(), and rl_config_read_default().
| int rl_config_validate | ( | rl_config_t const *const | config | ) |
Validate RocketLogger configuration.
| config | The measurement configuration to validate |
Definition at line 431 of file rl.c.
References rl_config::background_enable, rl_config::config_version, ERROR, rl_config::file_comment, rl_config::file_size, rl_config::interactive_enable, is_printable_string(), RL_CONFIG_FILE_SIZE_MIN, RL_CONFIG_VERSION, rl_log(), RL_LOG_ERROR, RL_SAMPLE_RATE_MIN, rl_config::sample_rate, SUCCESS, and rl_config::update_rate.
Here is the call graph for this function:| int rl_config_write_default | ( | rl_config_t const *const | config | ) |
Write provided configuration as default to file.
| config | The measurement configuration write as default configuration |
Definition at line 414 of file rl.c.
References ERROR, RL_CONFIG_USER_FILE, rl_log(), RL_LOG_ERROR, and SUCCESS.
Here is the call graph for this function:| pid_t rl_pid_get | ( | void | ) |
Get process ID (PID) of background sampling process.
Definition at line 508 of file rl.c.
References RL_PID_FILE.
Referenced by rl_stop().
| int rl_pid_set | ( | pid_t | pid | ) |
Store process ID (PID) of the RocketLogger process.
| pid | The PID of the running process to sture |
Definition at line 521 of file rl.c.
References ERROR, rl_log(), RL_LOG_ERROR, RL_PID_FILE, and SUCCESS.
Referenced by pru_sample().
Here is the call graph for this function:| char* rl_status_get_json | ( | rl_status_t const *const | status | ) |
Get RocketLogger status as JSON data structure string.
| status | The status data structure |
Definition at line 736 of file rl.c.
References rl_status::buffer_count, rl_status::calibration_file, rl_status::calibration_time, rl_status::config, rl_status::disk_free, rl_status::disk_free_permille, rl_status::disk_use_rate, rl_status::error, rl_config_get_json(), RL_JSON_BUFFER_SIZE, rl_status::sample_count, rl_status::sampling, rl_status::sensor_available, rl_status::sensor_count, SENSOR_REGISTRY, SENSOR_REGISTRY_SIZE, and snprintfcat().
Referenced by rl_status_print_json(), and rl_status_write().
Here is the call graph for this function:| void rl_status_print | ( | rl_status_t const *const | status | ) |
| void rl_status_print_json | ( | rl_status_t const *const | status | ) |
Print RocketLogger status as JSON data structure.
| status | The status data structure to print |
Definition at line 731 of file rl.c.
References rl_status_get_json().
Here is the call graph for this function:| int rl_status_pub_deinit | ( | void | ) |
Deinitialize the RocketLogger status publishing.
Definition at line 554 of file rl.c.
References SUCCESS, zmq_status_context, and zmq_status_publisher.
| int rl_status_pub_init | ( | void | ) |
Initialize the RocketLogger status publishing.
Definition at line 539 of file rl.c.
References ERROR, rl_log(), RL_LOG_ERROR, RL_ZMQ_STATUS_SOCKET, SUCCESS, zmq_status_context, and zmq_status_publisher.
Here is the call graph for this function:| int rl_status_read | ( | rl_status_t *const | status | ) |
Read the status of the RocketLogger from shared memory.
| status | The status data structure to write the read status to |
Definition at line 602 of file rl.c.
References rl_status::config, ERROR, rl_log(), RL_LOG_ERROR, RL_SHMEM_PERMISSIONS, RL_SHMEM_STATUS_KEY, and SUCCESS.
Referenced by button_interrupt_handler(), and rl_get_status().
Here is the call graph for this function:| void rl_status_reset | ( | rl_status_t *const | status | ) |
Get the RocketLogger default status.
| status | The status data structure to write the default value to |
Definition at line 535 of file rl.c.
References rl_status_default.
Referenced by adc_calibrate(), rl_get_status(), and rl_is_sampling().
| int rl_status_shm_deinit | ( | void | ) |
Deinitialize and remove the shared memory for the RocketLogger status.
Definition at line 579 of file rl.c.
References ERROR, rl_log(), RL_LOG_ERROR, RL_SHMEM_PERMISSIONS, RL_SHMEM_STATUS_KEY, and SUCCESS.
Here is the call graph for this function:| int rl_status_shm_init | ( | void | ) |
Create and initialize the shared memory for the RocketLogger status.
Definition at line 565 of file rl.c.
References ERROR, rl_log(), RL_LOG_ERROR, RL_SHMEM_PERMISSIONS, RL_SHMEM_STATUS_KEY, and SUCCESS.
Here is the call graph for this function:| int rl_status_write | ( | rl_status_t *const | status | ) |
Write new status of the RocketLogger to shared memory.
| status | The status data structure to copy to the shared memory |
Definition at line 641 of file rl.c.
References rl_status::config, rl_status::disk_free, rl_status::disk_free_permille, ERROR, rl_config::file_name, fs_space_free(), fs_space_total(), RL_CONFIG_FILE_DIR_DEFAULT, rl_log(), RL_LOG_ERROR, RL_SHMEM_PERMISSIONS, RL_SHMEM_STATUS_KEY, rl_status_get_json(), SUCCESS, and zmq_status_publisher.
Referenced by adc_calibrate(), hw_deinit(), hw_init(), and pru_sample().
Here is the call graph for this function:| char const* const RL_CHANNEL_DIGITAL_NAMES[RL_CHANNEL_DIGITAL_COUNT] |
RocketLogger digital channel names.
Definition at line 103 of file rl.c.
Referenced by meter_print_buffer(), and rl_file_setup_data_channels().
| char const* const RL_CHANNEL_FORCE_NAMES[RL_CHANNEL_SWITCHED_COUNT] |
RocketLogger force range channel names.
Definition at line 99 of file rl.c.
Referenced by rl_config_get_json(), and rl_config_print_cmd().
| char const* const RL_CHANNEL_NAMES[RL_CHANNEL_COUNT] |
RocketLogger channel names.
RocketLogger channel names sorted by name.
Definition at line 95 of file rl.c.
Referenced by meter_print_buffer(), rl_config_get_json(), rl_config_print_cmd(), rl_file_setup_data_channels(), and rl_socket_metadata().
| char const* const RL_CHANNEL_VALID_NAMES[RL_CHANNEL_SWITCHED_COUNT] |
RocketLogger valid channel names.
Definition at line 107 of file rl.c.
Referenced by rl_file_setup_data_channels().
| const rl_config_t rl_config_default |
RocketLogger reset configuration definition.
Definition at line 55 of file rl.c.
Referenced by rl_config_reset().
Global RocketLogger status variable.
Definition at line 112 of file rl.c.
Referenced by adc_calibrate().
| const rl_status_t rl_status_default |
RocketLogger reset status definition.
Definition at line 79 of file rl.c.
Referenced by rl_status_reset().
| void* zmq_status_context = NULL |
The ZeroMQ context for status publishing.
Definition at line 128 of file rl.c.
Referenced by rl_status_pub_deinit(), and rl_status_pub_init().
| void* zmq_status_publisher = NULL |
The ZeroMQ status publisher.
Definition at line 130 of file rl.c.
Referenced by rl_status_pub_deinit(), rl_status_pub_init(), and rl_status_write().