RocketLogger  1.1.6
util.h File Reference
#include <stdint.h>
#include "types.h"
+ Include dependency graph for util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  time_stamp
 

Macros

#define MAC_ADDRESS_LENGTH   6
 MAC address length in bytes. More...
 

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[])
 
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])
 

Macro Definition Documentation

#define MAC_ADDRESS_LENGTH   6

MAC address length in bytes.

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 40 of file util.h.

Referenced by file_store_header_csv(), and get_mac_addr().

Function Documentation

int ceil_div ( int  n,
int  d 
)

Integer division with ceiling.

Parameters
nNumerator
dDenominator
Returns
Result

Definition at line 164 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 80 of file util.c.

References CHANNEL_ENABLED, and NUM_CHANNELS.

Referenced by file_handle_data(), file_setup_lead_in(), meter_print_buffer(), pru_sample(), and web_handle_data().

void create_time_stamp ( struct time_stamp timestamp_realtime,
struct time_stamp timestamp_monotonic 
)

Create time stamps (real and monotonic)

Parameters
timestamp_realtimePointer to time_stamp struct
timestamp_monotonicPointer to time_stamp struct

Definition at line 223 of file util.c.

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

Referenced by ambient_setup_lead_in(), file_setup_lead_in(), and pru_sample().

+ 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 248 of file util.c.

References MAC_ADDRESS_FILE, and MAC_ADDRESS_LENGTH.

Referenced by ambient_setup_lead_in(), and file_setup_lead_in().

int is_current ( int  index)

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. 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 53 of file util.c.

References I1H_INDEX, I1L_INDEX, I2H_INDEX, and I2L_INDEX.

Referenced by file_setup_channels(), and meter_print_buffer().

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 67 of file util.c.

References I1L_INDEX, and I2L_INDEX.

Referenced by file_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 202 of file util.c.

References ERROR, FAILURE, and rl_log().

Referenced by pru_data_setup(), pru_map_memory(), pru_sample(), and pru_unmap_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 95 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 178 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 129 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: