|
RocketLogger 2.1.1
|
#include <stdbool.h>#include <stdint.h>#include <linux/limits.h>#include <sys/types.h>#include "version.h"
Include dependency graph for rl.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | rl_config |
| struct | rl_status |
Macros | |
| #define | SUCCESS (0) |
| Function return value for successful completion. | |
| #define | ERROR (-1) |
| Function return value for errors (use errno to indicate the error) | |
| #define | RL_MEASUREMENT_LOG_FILE "/var/log/rocketlogger/rocketlogger.log" |
| RocketLogger measurement log file. | |
| #define | RL_DAEMON_LOG_FILE "/var/log/rocketlogger/rocketloggerd.log" |
| RocketLogger daemon log file. | |
| #define | RL_PID_FILE "/run/rocketlogger.pid" |
| Process ID file for the RocketLogger process. | |
| #define | RL_CHANNEL_COUNT 9 |
| Number of RocketLogger analog channels. | |
| #define | RL_CHANNEL_SWITCHED_COUNT 2 |
| Number of RocketLogger switched channels (allowing to force range) | |
| #define | RL_CHANNEL_DIGITAL_COUNT 6 |
| Number of RocketLogger digital channels. | |
| #define | RL_SAMPLE_RATE_MIN 1000 |
| Minimum native sample rate of the ADC in samples per second. | |
| #define | RL_SENSOR_COUNT_MAX 128 |
| Maximum number of sensors that can be connected to the system. | |
| #define | RL_SENSOR_SAMPLE_RATE 1 |
| Ambient sensor read out rate in samples per second. | |
| #define | RL_CALIBRATION_USER_FILE "/home/rocketlogger/.config/rocketlogger/calibration.dat" |
| User folder calibration file path. | |
| #define | RL_CALIBRATION_SYSTEM_FILE "/etc/rocketlogger/calibration.dat" |
| Default system wide calibration file path. | |
| #define | RL_CONFIG_USER_FILE "/home/rocketlogger/.config/rocketlogger/settings.dat" |
| User configuration file path. | |
| #define | RL_CONFIG_SYSTEM_FILE "/etc/rocketlogger/settings.dat" |
| Default system configuration file path. | |
| #define | RL_CONFIG_VERSION 0x03 |
| Default system configuration file path. | |
| #define | RL_CONFIG_CHANNEL_V1 0 |
| Configuration channel indexes. | |
| #define | RL_CONFIG_CHANNEL_V2 1 |
| #define | RL_CONFIG_CHANNEL_V3 2 |
| #define | RL_CONFIG_CHANNEL_V4 3 |
| #define | RL_CONFIG_CHANNEL_I1L 4 |
| #define | RL_CONFIG_CHANNEL_I1H 5 |
| #define | RL_CONFIG_CHANNEL_I2L 6 |
| #define | RL_CONFIG_CHANNEL_I2H 7 |
| #define | RL_CONFIG_CHANNEL_DT 8 |
| #define | RL_CONFIG_CHANNEL_ENABLE_DEFAULT { true, true, true, true, true, true, true, true, false } |
| Configuration channel enable default. | |
| #define | RL_CONFIG_CHANNEL_I1 0 |
| Configuration merged/forced channel indexes. | |
| #define | RL_CONFIG_CHANNEL_I2 1 |
| #define | RL_CONFIG_CHANNEL_FORCE_RANGE_DEFAULT { false, false } |
| Configuration channel force range default. | |
| #define | RL_CONFIG_FILE_DIR_DEFAULT "/home/rocketlogger/data" |
| Configuration data file directory default. | |
| #define | RL_CONFIG_FILE_DEFAULT RL_CONFIG_FILE_DIR_DEFAULT "/data.rld" |
| Configuration file name default. | |
| #define | RL_CONFIG_FILE_SIZE_MIN (5UL * 1000UL * 1000UL) |
| Minimum measurement split file size (5 MB to fit largest block at max rate) | |
| #define | RL_CONFIG_FILE_SIZE_DEFAULT (1000UL * 1000UL * 1000UL) |
| Configuration file size default. | |
| #define | RL_CONFIG_COMMENT_DEFAULT "Sampled using the RocketLogger" |
| Configuration file comment default. | |
| #define | RL_SHMEM_STATUS_KEY 1111 |
| Key for status shared memory (used for creation) | |
| #define | RL_SHMEM_DATA_KEY 4443 |
| Key for web shared memory (used for creation) | |
| #define | RL_SHMEM_PERMISSIONS 0666 |
| Permissions for shared memory. | |
| #define | RL_ZMQ_STATUS_SOCKET "tcp://127.0.0.1:8276" |
| ZeroMQ socket identifier for status publishing. | |
| #define | RL_ZMQ_DATA_SOCKET "tcp://127.0.0.1:8277" |
| ZeroMQ socket identifier for data publishing status. | |
Typedefs | |
| typedef enum rl_aggregation_mode | rl_aggregation_mode_t |
| typedef enum rl_file_format | rl_file_format_t |
| typedef struct rl_config | rl_config_t |
| typedef struct rl_status | rl_status_t |
Enumerations | |
| enum | rl_aggregation_mode { RL_AGGREGATION_MODE_DOWNSAMPLE , RL_AGGREGATION_MODE_AVERAGE } |
| enum | rl_file_format { RL_FILE_FORMAT_CSV , RL_FILE_FORMAT_RLD } |
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 | |
| char const *const | RL_CHANNEL_NAMES [RL_CHANNEL_COUNT] |
| RocketLogger channel names sorted by name. | |
| char const *const | RL_CHANNEL_FORCE_NAMES [RL_CHANNEL_SWITCHED_COUNT] |
| RocketLogger force range channel names. | |
| char const *const | RL_CHANNEL_DIGITAL_NAMES [RL_CHANNEL_DIGITAL_COUNT] |
| RocketLogger digital channel names. | |
| char const *const | RL_CHANNEL_VALID_NAMES [RL_CHANNEL_SWITCHED_COUNT] |
| RocketLogger valid channel names. | |
| rl_status_t | rl_status |
| Global RocketLogger status variable. | |
| #define ERROR (-1) |
| #define RL_CALIBRATION_SYSTEM_FILE "/etc/rocketlogger/calibration.dat" |
| #define RL_CALIBRATION_USER_FILE "/home/rocketlogger/.config/rocketlogger/calibration.dat" |
| #define RL_CHANNEL_COUNT 9 |
| #define RL_CHANNEL_DIGITAL_COUNT 6 |
| #define RL_CHANNEL_SWITCHED_COUNT 2 |
| #define RL_CONFIG_CHANNEL_ENABLE_DEFAULT { true, true, true, true, true, true, true, true, false } |
| #define RL_CONFIG_CHANNEL_FORCE_RANGE_DEFAULT { false, false } |
| #define RL_CONFIG_CHANNEL_I1 0 |
| #define RL_CONFIG_COMMENT_DEFAULT "Sampled using the RocketLogger" |
| #define RL_CONFIG_FILE_DEFAULT RL_CONFIG_FILE_DIR_DEFAULT "/data.rld" |
| #define RL_CONFIG_FILE_DIR_DEFAULT "/home/rocketlogger/data" |
| #define RL_CONFIG_FILE_SIZE_DEFAULT (1000UL * 1000UL * 1000UL) |
| #define RL_CONFIG_FILE_SIZE_MIN (5UL * 1000UL * 1000UL) |
| #define RL_CONFIG_SYSTEM_FILE "/etc/rocketlogger/settings.dat" |
| #define RL_CONFIG_USER_FILE "/home/rocketlogger/.config/rocketlogger/settings.dat" |
| #define RL_CONFIG_VERSION 0x03 |
| #define RL_DAEMON_LOG_FILE "/var/log/rocketlogger/rocketloggerd.log" |
| #define RL_MEASUREMENT_LOG_FILE "/var/log/rocketlogger/rocketlogger.log" |
| #define RL_PID_FILE "/run/rocketlogger.pid" |
| #define RL_SAMPLE_RATE_MIN 1000 |
| #define RL_SENSOR_COUNT_MAX 128 |
| #define RL_SENSOR_SAMPLE_RATE 1 |
| #define RL_SHMEM_DATA_KEY 4443 |
| #define RL_SHMEM_PERMISSIONS 0666 |
| #define RL_SHMEM_STATUS_KEY 1111 |
| #define RL_ZMQ_DATA_SOCKET "tcp://127.0.0.1:8277" |
| #define RL_ZMQ_STATUS_SOCKET "tcp://127.0.0.1:8276" |
| #define SUCCESS (0) |
| typedef enum rl_aggregation_mode rl_aggregation_mode_t |
| typedef struct rl_config rl_config_t |
| typedef enum rl_file_format rl_file_format_t |
| typedef struct rl_status rl_status_t |
| enum rl_aggregation_mode |
| enum rl_file_format |
| 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 | ) |
Print RocketLogger configuration as text output.
| config | The measurement configuration to print |
Definition at line 142 of file rl.c.
References rl_config::aggregation_mode, rl_config::background_enable, rl_config::calibration_ignore, rl_config::channel_enable, rl_config::channel_force_range, rl_config::digital_enable, 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_CONFIG_CHANNEL_DT, RL_CONFIG_CHANNEL_I1, RL_CONFIG_CHANNEL_I1H, RL_CONFIG_CHANNEL_I1L, RL_CONFIG_CHANNEL_I2, RL_CONFIG_CHANNEL_I2H, RL_CONFIG_CHANNEL_I2L, RL_CONFIG_CHANNEL_V1, RL_CONFIG_CHANNEL_V2, RL_CONFIG_CHANNEL_V3, RL_CONFIG_CHANNEL_V4, RL_FILE_FORMAT_CSV, RL_FILE_FORMAT_RLD, rl_config::sample_limit, rl_config::sample_rate, rl_config::update_rate, and rl_config::web_enable.
Referenced by main().
| 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.
Referenced by main().
| 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().
Referenced by main().
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(), main(), 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.
Referenced by main().
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.
Referenced by main().
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 | ) |
Print RocketLogger status as text output.
| status | The status data structure to print |
Definition at line 709 of file rl.c.
References rl_status::buffer_count, rl_status::calibration_file, rl_status::calibration_time, rl_status::disk_free, rl_status::disk_free_permille, rl_status::disk_use_rate, rl_status::error, rl_status::sample_count, rl_status::sampling, rl_status::sensor_available, rl_status::sensor_count, SENSOR_REGISTRY, and SENSOR_REGISTRY_SIZE.
Referenced by main().
| 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().
Referenced by main().
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.
Referenced by rl_run().
| 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.
Referenced by rl_run().
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 adc_calibrate(), button_interrupt_handler(), main(), 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 rl_get_status(), rl_is_sampling(), and rl_run().
| 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.
Referenced by main().
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.
Referenced by main().
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(), pru_sample(), and rl_run().
Here is the call graph for this function:
|
extern |
RocketLogger digital channel names.
Definition at line 103 of file rl.c.
Referenced by meter_print_buffer(), and rl_file_setup_data_channels().
|
extern |
RocketLogger force range channel names.
Definition at line 99 of file rl.c.
Referenced by rl_config_get_json(), and rl_config_print_cmd().
|
extern |
RocketLogger channel names sorted by name.
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().
|
extern |
RocketLogger valid channel names.
Definition at line 107 of file rl.c.
Referenced by rl_file_setup_data_channels().
|
extern |