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

Go to the source code of this file.

Functions

int is_current (int index)
 
int is_low_current (int index)
 
int count_channels (int channels[NUM_CHANNELS])
 
int read_status (struct rl_status *status)
 
int write_status (struct rl_status *status)
 
int ceil_div (int n, int d)
 
void sig_handler (int signo)
 
int read_file_value (char filename[])
 

Function Documentation

int ceil_div ( int  n,
int  d 
)

Integer division with ceiling.

Parameters
nNumerator
dDenominator
Returns
Result

Definition at line 116 of file util.c.

Referenced by pru_sample().

int count_channels ( int  channels[NUM_CHANNELS])

Counts the number of channels sampled.

Parameters
channelsChannel array.
Returns
the number of sampled channels.

Definition at line 39 of file util.c.

References CHANNEL_ENABLED, and NUM_CHANNELS.

Referenced by handle_data_buffer(), meter_print_buffer(), pru_sample(), and setup_lead_in().

int is_current ( int  index)

Copyright (c) 2016-2017, ETH Zurich, Computer Engineering Group Checks if channel is a current channel.

Parameters
indexIndex of channel in array.
Returns
1, if channel is a current, 0 otherwise.

Definition at line 13 of file util.c.

References I1H_INDEX, I1L_INDEX, I2H_INDEX, and I2L_INDEX.

Referenced by meter_print_buffer(), and setup_channels().

int is_low_current ( int  index)

Checks if channel is a low range current channel.

Parameters
indexIndex of channel in array.
Returns
1, if channel is a low range current, 0 otherwise.

Definition at line 26 of file util.c.

References I1L_INDEX, and I2L_INDEX.

Referenced by setup_channels().

int read_file_value ( char  filename[])

Read a single integer from file.

Parameters
filenamePath to file.
Returns
integer value in the file, FAILURE when failed.

Definition at line 156 of file util.c.

References ERROR, FAILURE, and rl_log().

Referenced by map_pru_memory(), pru_data_setup(), pru_sample(), and unmap_pru_memory().

+ Here is the call graph for this function:

int read_status ( struct rl_status status)

Reads the status of the running measurement from shared memory.

Parameters
statusPointer to struct array.
Returns
SUCCESS in case of a success, FAILURE otherwise.

Definition at line 56 of file util.c.

References ERROR, FAILURE, rl_log(), SHMEM_PERMISSIONS, SHMEM_STATUS_KEY, and SUCCESS.

Referenced by rl_get_status(), and rl_read_status().

+ Here is the call graph for this function:

void sig_handler ( int  signo)

Signal handler to catch stop signals.

Parameters
signoSignal type.

Definition at line 131 of file util.c.

References rl_status::sampling, SAMPLING_OFF, and status.

Referenced by rl_start().

int write_status ( struct rl_status status)

Writes the status to the shared memory.

Parameters
statusPointer to struct array.
Returns
SUCCESS in case of a success, FAILURE otherwise.

Definition at line 85 of file util.c.

References ERROR, FAILURE, rl_log(), SHMEM_PERMISSIONS, SHMEM_STATUS_KEY, status, and SUCCESS.

Referenced by hw_close(), hw_init(), and pru_sample().

+ Here is the call graph for this function: