RocketLogger  1.0
file_handling.c File Reference
#include "file_handling.h"
+ Include dependency graph for file_handling.c:

Go to the source code of this file.

Functions

void create_time_stamp (struct time_stamp *time_real, struct time_stamp *time_monotonic)
 
void get_mac_addr (uint8_t mac_address[MAC_ADDRESS_LENGTH])
 
void setup_lead_in (struct rl_file_lead_in *lead_in, struct rl_conf *conf)
 
void setup_channels (struct rl_file_header *file_header, 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 merge_currents (uint8_t *valid, int64_t *dest, int64_t *src, struct rl_conf *conf)
 
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)
 

Variables

const char * channel_names [NUM_CHANNELS] = {"I1H","I1L","V1","V2","I2H","I2L","V3","V4"}
 Channel names. More...
 
const char * digital_input_names [NUM_DIGITAL_INPUTS] = {"DI1", "DI2", "DI3", "DI4", "DI5", "DI6"}
 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 create_time_stamp ( struct time_stamp time_real,
struct time_stamp time_monotonic 
)

Create time stamps (real and monotonic)

Parameters
time_realPointer to time_stamp struct
time_monotonicPointer to time_stamp struct

Definition at line 24 of file file_handling.c.

References ERROR, time_stamp::nsec, rl_log(), and time_stamp::sec.

Referenced by handle_data_buffer(), and setup_lead_in().

+ Here is the call graph for this function:

void get_mac_addr ( uint8_t  mac_address[MAC_ADDRESS_LENGTH])

Get MAC address of device

Parameters
mac_addressEmpty array with size MAC_ADDRESS_LENGTH

Definition at line 50 of file file_handling.c.

References MAC_ADDRESS_FILE, and MAC_ADDRESS_LENGTH.

Referenced by setup_lead_in().

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

Parameters
dataFile pointer to data file
buffer_addrPointer to buffer to handle
sample_sizeSize of samples to read
samples_bufferNumber of samples to read
confCurrent rl_conf configuration.
sem_idID of semaphores for shared web data
web_data_ptrPointer 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 merge_currents ( uint8_t *  valid,
int64_t *  dest,
int64_t *  src,
struct rl_conf conf 
)

Merge high/low currents for web interface

Parameters
validValid information of low range current channels
destPointer to destination array
srcPointer to source array
confPointer to current rl_conf configuration

Definition at line 327 of file file_handling.c.

References CHANNEL_ENABLED, rl_conf::channels, H_L_SCALE, I1H_INDEX, I1L_INDEX, I2H_INDEX, I2L_INDEX, V1_INDEX, V2_INDEX, V3_INDEX, and V4_INDEX.

Referenced by handle_data_buffer().

void setup_header ( struct rl_file_header file_header,
struct rl_conf conf 
)

Set up file header with current configuration

Parameters
file_headerPointer to rl_file_header to set up
confPointer 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 store_header_bin ( FILE *  data,
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 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 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

Parameters
dataFile pointer to data file
file_headerPointer 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

Parameters
dataFile pointer to data file
file_headerPointer 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().

Variable Documentation

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

Channel names.

Copyright (c) 2016-2017, ETH Zurich, Computer Engineering Group

Definition at line 8 of file file_handling.c.

Referenced by meter_print_buffer(), and setup_channels().

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

Digital input names.

Definition at line 10 of file file_handling.c.

Referenced by meter_print_buffer(), and setup_channels().

int i1l_valid_channel = 0

Global variable to determine i1l valid channel.

Definition at line 15 of file file_handling.c.

Referenced by setup_channels(), and setup_lead_in().

int i2l_valid_channel = 0

Global variable to determine i2l valid channel.

Definition at line 17 of file file_handling.c.

Referenced by setup_channels(), and 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 12 of file file_handling.c.

Referenced by setup_channels().