|
RocketLogger 2.1.0
|
#include <errno.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <linux/limits.h>#include <time.h>#include "log.h"#include "pru.h"#include "rl.h"#include "rl_file.h"#include "sensor/sensor.h"#include "util.h"
Include dependency graph for rl_file.c:Go to the source code of this file.
Functions | |
| void | rl_file_setup_data_channels (rl_file_header_t *const header, rl_config_t const *const config) |
| void | rl_file_setup_ambient_channels (rl_file_header_t *const header) |
| char * | rl_unit_to_string (rl_unit_t const unit) |
| char * | rl_file_get_ambient_file_name (char const *const data_file_name) |
| void | rl_file_setup_data_lead_in (rl_file_lead_in_t *const lead_in, rl_config_t const *const config) |
| void | rl_file_setup_ambient_lead_in (rl_file_lead_in_t *const lead_in, rl_config_t const *const config) |
| void | rl_file_setup_data_header (rl_file_header_t *const header, rl_config_t const *const config) |
| void | rl_file_setup_ambient_header (rl_file_header_t *const header, rl_config_t const *const config) |
| void | rl_file_store_header_bin (FILE *file_handle, rl_file_header_t *const file_header) |
| void | rl_file_store_header_csv (FILE *file_handle, rl_file_header_t const *const file_header) |
| void | rl_file_update_header_bin (FILE *file_handle, rl_file_header_t const *const file_header) |
| void | rl_file_update_header_csv (FILE *file_handle, rl_file_header_t const *const file_header) |
| int | rl_file_add_data_block (FILE *data_file, int32_t const *analog_buffer, uint32_t const *digital_buffer, size_t buffer_size, rl_timestamp_t const *const timestamp_realtime, rl_timestamp_t const *const timestamp_monotonic, rl_config_t const *const config) |
| int | rl_file_add_ambient_block (FILE *ambient_file, int32_t const *ambient_buffer, size_t buffer_size, rl_timestamp_t const *const timestamp_realtime, rl_timestamp_t const *const timestamp_monotonic, rl_config_t const *const config) |
Variables | |
| char * | RL_UNIT_NAMES [] |
| int | i1l_valid_channel = 0 |
| Global variable to determine i1l valid channel index. More... | |
| int | i2l_valid_channel = 0 |
| Global variable to determine i2l valid channel index. More... | |
| int rl_file_add_ambient_block | ( | FILE * | ambient_file, |
| int32_t const * | ambient_buffer, | ||
| size_t | buffer_size, | ||
| rl_timestamp_t const *const | timestamp_realtime, | ||
| rl_timestamp_t const *const | timestamp_monotonic, | ||
| rl_config_t const *const | config | ||
| ) |
Handle the sensor data buffer to add a new block to the ambient file.
| ambient_file | Ambient file to write to |
| ambient_buffer | Ambient sensor data buffer to process |
| buffer_size | Number of sensor samples in the buffer |
| timestamp_realtime | Timestamp sampled from realtime clock |
| timestamp_monotonic | Timestamp sampled from monotonic clock |
| config | Current measurement configuration |
Definition at line 521 of file rl_file.c.
Referenced by pru_sample().
| int rl_file_add_data_block | ( | FILE * | data_file, |
| int32_t const * | analog_buffer, | ||
| uint32_t const * | digital_buffer, | ||
| size_t | buffer_size, | ||
| rl_timestamp_t const *const | timestamp_realtime, | ||
| rl_timestamp_t const *const | timestamp_monotonic, | ||
| rl_config_t const *const | config | ||
| ) |
Handle the sampling data buffer to add a new block to the data file.
| data_file | Data file to write to |
| analog_buffer | Analog data buffer to process |
| digital_buffer | Digital data buffer to process |
| buffer_size | Number of data samples in the buffer |
| timestamp_realtime | Timestamp sampled from realtime clock |
| timestamp_monotonic | Timestamp sampled from monotonic clock |
| config | Current measurement configuration |
Definition at line 351 of file rl_file.c.
References rl_config::aggregation_mode, rl_config::channel_enable, data, rl_config::digital_enable, ERROR, rl_config::file_enable, rl_config::file_format, rl_timestamp::nsec, PRU_DIGITAL_I1L_VALID_MASK, PRU_DIGITAL_I2L_VALID_MASK, PRU_DIGITAL_INPUT1_MASK, PRU_DIGITAL_INPUT_MASK, RL_AGGREGATION_MODE_AVERAGE, RL_AGGREGATION_MODE_DOWNSAMPLE, RL_CHANNEL_COUNT, RL_CHANNEL_DIGITAL_COUNT, RL_CONFIG_CHANNEL_I1L, RL_CONFIG_CHANNEL_I2L, RL_FILE_CSV_DELIMITER, RL_FILE_FORMAT_CSV, RL_FILE_FORMAT_RLD, rl_log(), RL_LOG_ERROR, RL_LOG_WARNING, RL_SAMPLE_RATE_MIN, rl_config::sample_rate, and rl_timestamp::sec.
Referenced by pru_sample().
Here is the call graph for this function:| char * rl_file_get_ambient_file_name | ( | char const *const | data_file_name | ) |
Derive the ambient file name from the data file name.
| data_file_name | The data file name |
Definition at line 95 of file rl_file.c.
References RL_FILE_AMBIENT_SUFFIX.
Referenced by hw_sample(), and pru_sample().
| void rl_file_setup_ambient_channels | ( | rl_file_header_t *const | header | ) |
Set up channel information of the ambient file header.
| header | The ambient file header structure to configure |
| config | Current measurement configuration |
Definition at line 625 of file rl_file.c.
References rl_file_header::channel, rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, rl_file_channel::channel_scale, rl_file_channel::data_size, rl_file_header::lead_in, rl_file_channel::name, rl_sensor::name, RL_FILE_CHANNEL_NO_LINK, rl_sensor::scale, rl_status::sensor_available, SENSOR_REGISTRY, SENSOR_REGISTRY_SIZE, rl_file_channel::unit, rl_sensor::unit, and rl_file_channel::valid_data_channel.
Referenced by rl_file_setup_ambient_header().
| void rl_file_setup_ambient_header | ( | rl_file_header_t *const | file_header, |
| rl_config_t const *const | config | ||
| ) |
Set up ambient file header with current configuration.
| file_header | The file header data structure to set up |
| config | Current measurement configuration |
Definition at line 207 of file rl_file.c.
References rl_file_header::comment, rl_config::file_comment, and rl_file_setup_ambient_channels().
Referenced by pru_sample().
Here is the call graph for this function:| void rl_file_setup_ambient_lead_in | ( | rl_file_lead_in_t *const | lead_in, |
| rl_config_t const *const | config | ||
| ) |
Set up ambient file header lead-in with current configuration.
| lead_in | The file lead-in data structure to set up |
| config | Current measurement configuration |
Definition at line 161 of file rl_file.c.
References rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, rl_file_lead_in::comment_length, create_time_stamp(), rl_file_lead_in::data_block_count, rl_file_lead_in::data_block_size, rl_file_lead_in::file_magic, rl_file_lead_in::file_version, get_mac_addr(), rl_file_lead_in::header_length, rl_file_lead_in::mac_address, RL_FILE_AMBIENT_DATA_BLOCK_SIZE, RL_FILE_COMMENT_ALIGNMENT_BYTES, RL_FILE_MAGIC, RL_FILE_VERSION, RL_SENSOR_SAMPLE_RATE, rl_file_lead_in::sample_count, rl_file_lead_in::sample_rate, rl_status::sensor_count, rl_file_lead_in::start_time, and rl_config::update_rate.
Referenced by pru_sample().
Here is the call graph for this function:| void rl_file_setup_data_channels | ( | rl_file_header_t *const | header, |
| rl_config_t const *const | config | ||
| ) |
Set up channel information of the data file header.
| header | The file header structure to configure |
| config | Current measurement configuration |
Definition at line 539 of file rl_file.c.
References rl_config::calibration_ignore, rl_file_header::channel, rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, rl_config::channel_enable, rl_file_channel::channel_scale, rl_file_channel::data_size, rl_config::digital_enable, i1l_valid_channel, i2l_valid_channel, is_current(), is_low_current(), is_voltage(), rl_file_header::lead_in, rl_file_channel::name, RL_CHANNEL_COUNT, RL_CHANNEL_DIGITAL_COUNT, RL_CHANNEL_DIGITAL_NAMES, RL_CHANNEL_NAMES, RL_CHANNEL_VALID_NAMES, RL_CONFIG_CHANNEL_I1L, RL_CONFIG_CHANNEL_I2L, RL_FILE_CHANNEL_NAME_LENGTH, RL_FILE_CHANNEL_NO_LINK, RL_SCALE_NANO, RL_SCALE_TEN_NANO, RL_SCALE_TEN_PICO, RL_SCALE_UNIT, RL_UNIT_AMPERE, RL_UNIT_BINARY, RL_UNIT_RANGE_VALID, RL_UNIT_SECOND, RL_UNIT_UNDEFINED, RL_UNIT_VOLT, rl_file_channel::unit, and rl_file_channel::valid_data_channel.
Referenced by rl_file_setup_data_header().
Here is the call graph for this function:| void rl_file_setup_data_header | ( | rl_file_header_t *const | file_header, |
| rl_config_t const *const | config | ||
| ) |
Set up data file header with current configuration.
| file_header | The file header data structure to set up |
| config | Current measurement configuration |
Definition at line 196 of file rl_file.c.
References rl_file_header::comment, rl_config::file_comment, and rl_file_setup_data_channels().
Referenced by pru_sample().
Here is the call graph for this function:| void rl_file_setup_data_lead_in | ( | rl_file_lead_in_t *const | lead_in, |
| rl_config_t const *const | config | ||
| ) |
Set up data file header lead-in with current configuration.
| lead_in | The file lead-in data structure to set up |
| config | Current measurement configuration |
Definition at line 119 of file rl_file.c.
References rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, rl_config::channel_enable, rl_file_lead_in::comment_length, count_channels(), create_time_stamp(), rl_file_lead_in::data_block_count, rl_file_lead_in::data_block_size, rl_config::digital_enable, rl_file_lead_in::file_magic, rl_file_lead_in::file_version, get_mac_addr(), rl_file_lead_in::header_length, i1l_valid_channel, i2l_valid_channel, rl_file_lead_in::mac_address, RL_CHANNEL_DIGITAL_COUNT, RL_CONFIG_CHANNEL_I1L, RL_CONFIG_CHANNEL_I2L, RL_FILE_COMMENT_ALIGNMENT_BYTES, RL_FILE_MAGIC, RL_FILE_VERSION, rl_file_lead_in::sample_count, rl_config::sample_rate, rl_file_lead_in::sample_rate, rl_file_lead_in::start_time, and rl_config::update_rate.
Referenced by pru_sample().
Here is the call graph for this function:| void rl_file_store_header_bin | ( | FILE * | file_handle, |
| rl_file_header_t *const | file_header | ||
| ) |
Store file header to file (in binary format).
| file_handle | Data file to write to |
| file_header | The file header data structure to store to the file |
Definition at line 218 of file rl_file.c.
References rl_file_header::channel, rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, rl_file_header::comment, rl_file_lead_in::comment_length, rl_file_lead_in::header_length, rl_file_header::lead_in, and RL_FILE_COMMENT_ALIGNMENT_BYTES.
Referenced by pru_sample().
| void rl_file_store_header_csv | ( | FILE * | file_handle, |
| rl_file_header_t const *const | file_header | ||
| ) |
Store file header to file (in CSV format).
| file_handle | Data file to write to |
| file_header | The file header data structure to store to the file |
Definition at line 255 of file rl_file.c.
References rl_file_header::channel, rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, rl_file_channel::channel_scale, rl_file_header::comment, rl_file_lead_in::data_block_count, rl_file_lead_in::data_block_size, rl_file_lead_in::file_version, rl_file_header::lead_in, rl_file_lead_in::mac_address, MAC_ADDRESS_LENGTH, rl_file_channel::name, RL_SCALE_MICRO, RL_SCALE_MILLI, RL_SCALE_NANO, RL_SCALE_TEN_NANO, RL_SCALE_TEN_PICO, RL_UNIT_AMPERE, RL_UNIT_SECOND, RL_UNIT_VOLT, rl_file_lead_in::sample_count, rl_file_lead_in::sample_rate, rl_timestamp::sec, rl_file_lead_in::start_time, and rl_file_channel::unit.
Referenced by pru_sample().
| void rl_file_update_header_bin | ( | FILE * | file_handle, |
| rl_file_header_t const *const | file_header | ||
| ) |
Update file with new header lead-in (to write current sample count) in binary format.
| file_handle | Data file to write to |
| file_header | The file header data structure to store to the file |
Definition at line 325 of file rl_file.c.
References rl_file_header::lead_in.
Referenced by pru_sample().
| void rl_file_update_header_csv | ( | FILE * | file_handle, |
| rl_file_header_t const *const | file_header | ||
| ) |
Update file with new header lead-in (to write current sample count) in CSV format.
| file_handle | Data file to write to |
| file_header | The file header data structure to store to the file |
Definition at line 335 of file rl_file.c.
References rl_file_lead_in::data_block_count, rl_file_lead_in::data_block_size, rl_file_lead_in::file_version, rl_file_header::lead_in, and rl_file_lead_in::sample_count.
Referenced by pru_sample().
| char * rl_unit_to_string | ( | rl_unit_t | unit | ) |
Get the string representing the unit.
| unit | The unit to convert into a string |
Definition at line 86 of file rl_file.c.
References RL_UNIT_NAMES.
Referenced by rl_socket_metadata().
| int i1l_valid_channel = 0 |
Global variable to determine i1l valid channel index.
Definition at line 82 of file rl_file.c.
Referenced by rl_file_setup_data_channels(), and rl_file_setup_data_lead_in().
| int i2l_valid_channel = 0 |
Global variable to determine i2l valid channel index.
Definition at line 84 of file rl_file.c.
Referenced by rl_file_setup_data_channels(), and rl_file_setup_data_lead_in().
| char* RL_UNIT_NAMES[] |
Definition at line 50 of file rl_file.c.
Referenced by rl_unit_to_string().