RocketLogger  1.1.4
lib_util.c File Reference
#include "rl_util.h"
+ Include dependency graph for lib_util.c:

Go to the source code of this file.

Macros

#define NUMBER_SAMPLE_RATES   10
 Number of possible sampling rates. More...
 
#define NUMBER_UPDATE_RATES   4
 Number of possible update rates. More...
 

Functions

int check_sample_rate (int sample_rate)
 
int check_update_rate (int update_rate)
 
pid_t get_pid (void)
 
int set_pid (pid_t pid)
 

Variables

int possible_sample_rates [NUMBER_SAMPLE_RATES]
 Possible sampling rates. More...
 
int possible_update_rates [NUMBER_UPDATE_RATES] = {1, 2, 5, 10}
 Possible update rates. More...
 

Macro Definition Documentation

#define NUMBER_SAMPLE_RATES   10

Number of possible sampling rates.

Copyright (c) 2016-2018, 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 35 of file lib_util.c.

Referenced by check_sample_rate().

#define NUMBER_UPDATE_RATES   4

Number of possible update rates.

Definition at line 41 of file lib_util.c.

Referenced by check_update_rate().

Function Documentation

int check_sample_rate ( int  sample_rate)

Check if provided sampling rate is possible

Parameters
sample_rateSampling rate
Returns
SUCCESS if possible, FAILURE otherwise

Definition at line 50 of file lib_util.c.

References FAILURE, NUMBER_SAMPLE_RATES, possible_sample_rates, and SUCCESS.

Referenced by parse_args(), and rl_start().

int check_update_rate ( int  update_rate)

Check if provided update rate is possible

Parameters
update_rateUpdate rate
Returns
SUCCESS if possible, FAILURE otherwise

Definition at line 64 of file lib_util.c.

References FAILURE, NUMBER_UPDATE_RATES, possible_update_rates, and SUCCESS.

Referenced by parse_args(), and rl_start().

pid_t get_pid ( void  )

Get process ID (PID) of background sampling process

Returns
PID of background process

Definition at line 77 of file lib_util.c.

References FAILURE, and PID_FILE.

Referenced by rl_get_status(), rl_read_status(), and rl_stop().

int set_pid ( pid_t  pid)

Store process ID (PID)

Parameters
pidOwn PID
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 100 of file lib_util.c.

References ERROR, FAILURE, PID_FILE, rl_log(), and SUCCESS.

Referenced by rl_start().

+ Here is the call graph for this function:

Variable Documentation

int possible_sample_rates[NUMBER_SAMPLE_RATES]
Initial value:
= {
1, 10, 100, 1000, 2000, 4000, 8000, 16000, 32000, 64000}

Possible sampling rates.

Definition at line 37 of file lib_util.c.

Referenced by check_sample_rate().

int possible_update_rates[NUMBER_UPDATE_RATES] = {1, 2, 5, 10}

Possible update rates.

Definition at line 43 of file lib_util.c.

Referenced by check_update_rate().