RocketLogger  1.1.5
file_handling.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include "pru.h"
#include "util.h"
#include "file_handling.h"
+ Include dependency graph for file_handling.c:

Go to the source code of this file.

Functions

void file_setup_lead_in (struct rl_file_lead_in *lead_in, struct rl_conf *conf)
 
void file_setup_channels (struct rl_file_header *file_header, struct rl_conf *conf)
 
void file_setup_header (struct rl_file_header *file_header, struct rl_conf *conf, char *comment)
 
void file_store_header_bin (FILE *data_file, struct rl_file_header *file_header)
 
void file_store_header_csv (FILE *data_file, struct rl_file_header *file_header)
 
void file_update_header_bin (FILE *data_file, struct rl_file_header *file_header)
 
void file_update_header_csv (FILE *data_file, struct rl_file_header *file_header)
 
void file_handle_data (FILE *data_file, void *buffer_addr, uint32_t sample_data_size, uint32_t samples_count, struct time_stamp *timestamp_realtime, struct time_stamp *timestamp_monotonic, struct rl_conf *conf)
 

Variables

const char * channel_names [NUM_CHANNELS]
 Channel names. More...
 
const char * digital_input_names [NUM_DIGITAL_INPUTS]
 Digital input names. More...
 
const char * valid_info_names [NUM_I_CHANNELS] = {"I1L_valid", "I2L_valid"}
 Valid channel names. More...
 
int i1l_valid_channel = 0
 Global variable to determine i1l valid channel. More...
 
int i2l_valid_channel = 0
 Global variable to determine i2l valid channel. More...
 

Function Documentation

void file_handle_data ( FILE *  data_file,
void *  buffer_addr,
uint32_t  sample_data_size,
uint32_t  samples_count,
struct time_stamp timestamp_realtime,
struct time_stamp timestamp_monotonic,
struct rl_conf conf 
)

Handle a data buffer, dependent on current configuration

Parameters
data_fileFile pointer to data file
buffer_addrPointer to buffer to handle
sample_data_sizeData size of the samples in bytes
samples_countNumber of samples to read
timestamp_realtimetime_stamp with realtime clock value
timestamp_monotonictime_stamp with monotonic clock value
confCurrent rl_conf configuration.

Definition at line 364 of file file_handling.c.

References AGGREGATE_AVERAGE, AGGREGATE_DOWNSAMPLE, AGGREGATE_NONE, rl_conf::aggregation, BIN, BINARY_MASK, calibration, CHANNEL_ENABLED, rl_conf::channels, count_channels(), CSV, CSV_DELIMITER, rl_conf::digital_inputs, DIGITAL_INPUTS_ENABLED, ERROR, rl_conf::file_format, I1L_INDEX, I2L_INDEX, MIN_ADC_RATE, NO_FILE, time_stamp::nsec, num_channels, NUM_CHANNELS, NUM_DIGITAL_INPUTS, rl_calibration::offsets, PRU_DIG_SIZE, rl_log(), rl_conf::sample_rate, rl_calibration::scales, time_stamp::sec, and VALID_MASK.

Referenced by pru_sample().

+ Here is the call graph for this function:

void file_setup_header ( struct rl_file_header file_header,
struct rl_conf conf,
char *  comment 
)

Set up file header with current configuration

Parameters
file_headerPointer to rl_file_header to set up
confPointer to current rl_conf struct
commentThe comment stored in the file header or NULL for default

Definition at line 186 of file file_handling.c.

References rl_file_header::comment, and file_setup_channels().

Referenced by pru_sample().

+ Here is the call graph for this function:

void file_store_header_bin ( FILE *  data_file,
struct rl_file_header file_header 
)

Store file header to file (in binary format)

Parameters
dataFile pointer to data file
file_headerPointer to rl_file_header struct

Definition at line 205 of file file_handling.c.

References 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 file_update_header_bin ( FILE *  data_file,
struct rl_file_header file_header 
)

Update file with new header lead-in (to write current sample count) in binary format

Parameters
data_fileFile pointer to data file
file_headerPointer to rl_file_header struct

Definition at line 321 of file file_handling.c.

References rl_file_header::lead_in.

Referenced by pru_sample().

void file_update_header_csv ( FILE *  data_file,
struct rl_file_header file_header 
)

Update file with new header lead-in (to write current sample count) in CSV format

Parameters
data_fileFile pointer to data file
file_headerPointer to rl_file_header struct

Definition at line 338 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().

Variable Documentation

const char* channel_names[NUM_CHANNELS]
Initial value:
= {"I1H", "I1L", "V1", "V2",
"I2H", "I2L", "V3", "V4"}

Channel names.

Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 42 of file file_handling.c.

Referenced by file_setup_channels(), and meter_print_buffer().

const char* digital_input_names[NUM_DIGITAL_INPUTS]
Initial value:
= {"DI1", "DI2", "DI3",
"DI4", "DI5", "DI6"}

Digital input names.

Definition at line 45 of file file_handling.c.

Referenced by file_setup_channels(), and meter_print_buffer().

int i1l_valid_channel = 0

Global variable to determine i1l valid channel.

Definition at line 51 of file file_handling.c.

Referenced by file_setup_channels(), and file_setup_lead_in().

int i2l_valid_channel = 0

Global variable to determine i2l valid channel.

Definition at line 53 of file file_handling.c.

Referenced by file_setup_channels(), and file_setup_lead_in().

const char* valid_info_names[NUM_I_CHANNELS] = {"I1L_valid", "I2L_valid"}

Valid channel names.

Range valid information names.

Definition at line 48 of file file_handling.c.

Referenced by file_setup_channels().