|
RocketLogger
1.0
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include "types.h"#include "rl_file.h"#include "log.h"#include "util.h"#include "sem.h"#include "web.h"
Include dependency graph for file_handling.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | VALID_MASK 0x1 |
| Mask for valid bit read from PRU. More... | |
| #define | BINARY_MASK 0xE |
| Mask for binary inputs read from PRU. More... | |
| #define | H_L_SCALE 100 |
| Current high-low scale difference. More... | |
| #define | CSV_LINE_LENGTH 200 |
| Max length of a CSV file line. More... | |
| #define | CSV_VALUE_LENGTH 50 |
| Max length of a CSV value. More... | |
Functions | |
| void | setup_lead_in (struct rl_file_lead_in *lead_in, struct rl_conf *conf) |
| void | setup_header (struct rl_file_header *file_header, struct rl_conf *conf) |
| void | store_header_bin (FILE *data, struct rl_file_header *file_header) |
| void | store_header_csv (FILE *data, struct rl_file_header *file_header) |
| void | update_header_bin (FILE *data, struct rl_file_header *file_header) |
| void | update_header_csv (FILE *data, struct rl_file_header *file_header) |
| void | handle_data_buffer (FILE *data, void *buffer_addr, uint32_t sample_size, uint32_t samples_buffer, struct rl_conf *conf, int sem_id, struct web_shm *web_data_ptr) |
| #define BINARY_MASK 0xE |
Mask for binary inputs read from PRU.
Definition at line 24 of file file_handling.h.
Referenced by handle_data_buffer().
| #define CSV_LINE_LENGTH 200 |
Max length of a CSV file line.
Definition at line 30 of file file_handling.h.
Referenced by handle_data_buffer().
| #define CSV_VALUE_LENGTH 50 |
Max length of a CSV value.
Definition at line 32 of file file_handling.h.
Referenced by handle_data_buffer().
| #define H_L_SCALE 100 |
Current high-low scale difference.
Definition at line 27 of file file_handling.h.
Referenced by merge_currents().
| #define VALID_MASK 0x1 |
Mask for valid bit read from PRU.
Copyright (c) 2016-2017, ETH Zurich, Computer Engineering Group
Definition at line 22 of file file_handling.h.
Referenced by handle_data_buffer().
| void handle_data_buffer | ( | FILE * | data, |
| void * | buffer_addr, | ||
| uint32_t | sample_size, | ||
| uint32_t | samples_buffer, | ||
| struct rl_conf * | conf, | ||
| int | sem_id, | ||
| struct web_shm * | web_data_ptr | ||
| ) |
Handle a data buffer, dependent on current configuration
| data | File pointer to data file |
| buffer_addr | Pointer to buffer to handle |
| sample_size | Size of samples to read |
| samples_buffer | Number of samples to read |
| conf | Current rl_conf configuration. |
| sem_id | ID of semaphores for shared web data |
| web_data_ptr | Pointer to shared web data |
Definition at line 383 of file file_handling.c.
References BIN, BINARY_MASK, BUF100_INDEX, BUF10_INDEX, BUF1_INDEX, web_shm::buffer, BUFFER100_SIZE, BUFFER10_SIZE, BUFFER1_SIZE, buffer_add(), calibration, CHANNEL_ENABLED, rl_conf::channels, count_channels(), create_time_stamp(), CSV, CSV_LINE_LENGTH, CSV_VALUE_LENGTH, DATA_SEM, rl_conf::digital_inputs, DIGITAL_INPUTS_ENABLED, rl_conf::enable_web_server, rl_conf::file_format, I1L_INDEX, I2L_INDEX, merge_currents(), MIN_ADC_RATE, time_stamp::nsec, num_channels, web_shm::num_channels, NUM_CHANNELS, NUM_DIGITAL_INPUTS, NUM_I_CHANNELS, rl_calibration::offsets, PRU_DIG_SIZE, rl_log(), RL_RUNNING, rl_conf::sample_rate, rl_calibration::scales, time_stamp::sec, SEM_WRITE_TIME_OUT, set_sem(), rl_status::state, status, web_shm::time, TIME_OUT, rl_conf::update_rate, VALID_MASK, wait_sem(), WARNING, web_data, and WEB_RING_BUFFER_COUNT.
Referenced by pru_sample().
Here is the call graph for this function:| void setup_header | ( | struct rl_file_header * | file_header, |
| struct rl_conf * | conf | ||
| ) |
Set up file header with current configuration
| file_header | Pointer to rl_file_header to set up |
| conf | Pointer to current rl_conf struct |
Definition at line 188 of file file_handling.c.
References rl_file_header::comment, RL_FILE_COMMENT, and setup_channels().
Referenced by pru_sample().
Here is the call graph for this function:| void setup_lead_in | ( | struct rl_file_lead_in * | lead_in, |
| struct rl_conf * | conf | ||
| ) |
Set up file header lead-in with current configuration
| lead_in | Pointer to rl_file_lead_in struct to set up |
| conf | Pointer to current rl_conf struct |
Definition at line 67 of file file_handling.c.
References rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, CHANNEL_ENABLED, rl_conf::channels, 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_conf::digital_inputs, DIGITAL_INPUTS_ENABLED, rl_file_lead_in::file_version, get_mac_addr(), rl_file_lead_in::header_length, I1L_INDEX, i1l_valid_channel, I2L_INDEX, i2l_valid_channel, rl_file_lead_in::mac_address, rl_file_lead_in::magic, NUM_DIGITAL_INPUTS, RL_FILE_COMMENT, RL_FILE_MAGIC, RL_FILE_VERSION, rl_file_lead_in::sample_count, rl_file_lead_in::sample_rate, rl_conf::sample_rate, rl_file_lead_in::start_time, and rl_conf::update_rate.
Referenced by pru_sample().
Here is the call graph for this function:| void store_header_bin | ( | FILE * | data, |
| struct rl_file_header * | file_header | ||
| ) |
Store file header to file (in binary format)
| data | File pointer to data file |
| file_header | Pointer to rl_file_header struct |
Definition at line 204 of file file_handling.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 store_header_csv | ( | FILE * | data, |
| struct rl_file_header * | file_header | ||
| ) |
Store file header to file (in CSV format)
| data | File pointer to data file |
| file_header | Pointer to rl_file_header struct |
Definition at line 237 of file file_handling.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_VOLT, rl_file_lead_in::sample_count, rl_file_lead_in::sample_rate, time_stamp::sec, rl_file_lead_in::start_time, and rl_file_channel::unit.
Referenced by pru_sample().
| void update_header_bin | ( | FILE * | data, |
| struct rl_file_header * | file_header | ||
| ) |
Update file with new header lead-in (to write current sample count) in binary format
| data | File pointer to data file |
| file_header | Pointer to rl_file_header struct |
Definition at line 297 of file file_handling.c.
References rl_file_header::lead_in.
Referenced by pru_sample().
| void update_header_csv | ( | FILE * | data, |
| struct rl_file_header * | file_header | ||
| ) |
Update file with new header lead-in (to write current sample count) in CSV format
| data | File pointer to data file |
| file_header | Pointer to rl_file_header struct |
Definition at line 310 of file file_handling.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().