38 #include <linux/limits.h>
39 #include <sys/types.h>
49 #define RL_MEASUREMENT_LOG_FILE "/var/log/rocketlogger/rocketlogger.log"
51 #define RL_DAEMON_LOG_FILE "/var/log/rocketlogger/rocketloggerd.log"
53 #define RL_PID_FILE "/run/rocketlogger.pid"
56 #define RL_CHANNEL_COUNT 9
58 #define RL_CHANNEL_SWITCHED_COUNT 2
60 #define RL_CHANNEL_DIGITAL_COUNT 6
62 #define RL_SAMPLE_RATE_MIN 1000
64 #define RL_SENSOR_COUNT_MAX 128
66 #define RL_SENSOR_SAMPLE_RATE 1
69 #define RL_CALIBRATION_USER_FILE \
70 "/home/rocketlogger/.config/rocketlogger/calibration.dat"
72 #define RL_CALIBRATION_SYSTEM_FILE "/etc/rocketlogger/calibration.dat"
75 #define RL_CONFIG_USER_FILE \
76 "/home/rocketlogger/.config/rocketlogger/settings.dat"
78 #define RL_CONFIG_SYSTEM_FILE "/etc/rocketlogger/settings.dat"
81 #define RL_CONFIG_VERSION 0x03
83 #define RL_CONFIG_CHANNEL_V1 0
84 #define RL_CONFIG_CHANNEL_V2 1
85 #define RL_CONFIG_CHANNEL_V3 2
86 #define RL_CONFIG_CHANNEL_V4 3
87 #define RL_CONFIG_CHANNEL_I1L 4
88 #define RL_CONFIG_CHANNEL_I1H 5
89 #define RL_CONFIG_CHANNEL_I2L 6
90 #define RL_CONFIG_CHANNEL_I2H 7
91 #define RL_CONFIG_CHANNEL_DT 8
93 #define RL_CONFIG_CHANNEL_ENABLE_DEFAULT \
94 { true, true, true, true, true, true, true, true, false }
96 #define RL_CONFIG_CHANNEL_I1 0
97 #define RL_CONFIG_CHANNEL_I2 1
99 #define RL_CONFIG_CHANNEL_FORCE_RANGE_DEFAULT \
103 #define RL_CONFIG_FILE_DIR_DEFAULT "/home/rocketlogger/data"
105 #define RL_CONFIG_FILE_DEFAULT RL_CONFIG_FILE_DIR_DEFAULT "/data.rld"
107 #define RL_CONFIG_FILE_SIZE_MIN (5UL * 1000UL * 1000UL)
109 #define RL_CONFIG_FILE_SIZE_DEFAULT (1000UL * 1000UL * 1000UL)
111 #define RL_CONFIG_COMMENT_DEFAULT "Sampled using the RocketLogger"
114 #define RL_SHMEM_STATUS_KEY 1111
116 #define RL_SHMEM_DATA_KEY 4443
118 #define RL_SHMEM_PERMISSIONS 0666
121 #define RL_ZMQ_STATUS_SOCKET "tcp://127.0.0.1:8276"
123 #define RL_ZMQ_DATA_SOCKET "tcp://127.0.0.1:8277"
char const *const RL_CHANNEL_NAMES[RL_CHANNEL_COUNT]
RocketLogger channel names sorted by name.
void rl_status_print_json(rl_status_t const *const status)
void rl_status_reset(rl_status_t *const status)
char const *const RL_CHANNEL_FORCE_NAMES[RL_CHANNEL_SWITCHED_COUNT]
RocketLogger force range channel names.
char const *const RL_CHANNEL_VALID_NAMES[RL_CHANNEL_SWITCHED_COUNT]
RocketLogger valid channel names.
int rl_status_pub_init(void)
int rl_status_write(rl_status_t *const status)
@ RL_FILE_FORMAT_RLD
CSV format.
void rl_config_print_json(rl_config_t const *const config)
void rl_config_reset(rl_config_t *const config)
int rl_status_read(rl_status_t *const status)
enum rl_aggregation_mode rl_aggregation_mode_t
int rl_status_shm_init(void)
int rl_pid_set(pid_t pid)
void rl_config_print(rl_config_t const *const config)
int rl_config_read_default(rl_config_t *const config)
int rl_config_write_default(rl_config_t const *const config)
#define RL_CHANNEL_SWITCHED_COUNT
Number of RocketLogger switched channels (allowing to force range)
int rl_config_validate(rl_config_t const *const config)
void rl_status_print(rl_status_t const *const status)
char * rl_config_get_json(rl_config_t const *const config)
int rl_status_shm_deinit(void)
#define RL_CHANNEL_DIGITAL_COUNT
Number of RocketLogger digital channels.
enum rl_file_format rl_file_format_t
#define RL_CHANNEL_COUNT
Number of RocketLogger analog channels.
char * rl_status_get_json(rl_status_t const *const status)
void rl_config_print_cmd(rl_config_t const *const config)
int rl_status_pub_deinit(void)
rl_status_t rl_status
Global RocketLogger status variable.
char const *const RL_CHANNEL_DIGITAL_NAMES[RL_CHANNEL_DIGITAL_COUNT]
RocketLogger digital channel names.
#define RL_SENSOR_COUNT_MAX
Maximum number of sensors that can be connected to the system.
@ RL_AGGREGATION_MODE_AVERAGE
Aggregate using down sampling.
@ RL_AGGREGATION_MODE_DOWNSAMPLE
bool channel_force_range[RL_CHANNEL_SWITCHED_COUNT]
Current channels to force to high range.
char file_name[PATH_MAX]
Data file name.
bool interactive_enable
Display measurement data interactively in CLI while sampling.
char const * file_comment
File comment.
uint64_t file_size
Maximum data file size.
rl_aggregation_mode_t aggregation_mode
Sample aggregation mode (for sampling rates below lowest native one)
bool background_enable
Put the measurement process in background after successful start.
bool ambient_enable
Enable logging of ambient sensor.
uint64_t sample_limit
Sample limit (0 for continuous)
bool web_enable
Enable web interface connection.
rl_file_format_t file_format
File format.
uint32_t sample_rate
Sampling rate.
bool channel_enable[RL_CHANNEL_COUNT]
Channels to sample.
uint8_t config_version
Configuration structure version.
uint32_t update_rate
Data update rate.
bool file_enable
Enable storing measurements to file.
bool digital_enable
Enable digital inputs.
bool calibration_ignore
Perform calibration measurement (ignore existing calibration)
uint64_t disk_free
Time stamp of last calibration run.
rl_config_t const * config
(local) reference to current config
uint64_t buffer_count
Number of buffers taken.
uint16_t disk_free_permille
Time stamp of last calibration run.
uint64_t calibration_time
Time stamp of last calibration run.
bool error
Whether the logger is in an error state.
bool sampling
Sampling state, true: sampling, false: idle.
uint32_t disk_use_rate
Disk space in bytes required per minute when sampling.
uint16_t sensor_count
Number of sensors found connected to the system.
bool sensor_available[RL_SENSOR_COUNT_MAX]
Identifiers of sensors found.
uint64_t sample_count
Number of samples taken.
char calibration_file[PATH_MAX]
Time stamp of last calibration run.