RocketLogger  1.0
file_handling.h File Reference
#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)
 

Macro Definition Documentation

#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().

Function Documentation

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 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().