rtl433  UNKNOWN
RTL-433 utility
r_util.h File Reference

Various utility functions for use by applications. More...

Go to the source code of this file.

Functions

void get_time_now (struct timeval *tv)
 Get current time with usec precision. More...
 
char * format_time_str (char *buf, char const *format, time_t time_secs)
 Printable timestamp in local time. More...
 
char * usecs_time_str (char *buf, char const *format, struct timeval *tv)
 Printable timestamp in local time with microseconds. More...
 
char * sample_pos_str (float sample_file_pos, char *buf)
 Printable sample position. More...
 
float celsius2fahrenheit (float celsius)
 Convert Celsius to Fahrenheit. More...
 
float fahrenheit2celsius (float fahrenheit)
 Convert Fahrenheit to Celsius. More...
 
float kmph2mph (float kph)
 Convert Kilometers per hour (kph) to Miles per hour (mph). More...
 
float mph2kmph (float kph)
 Convert Miles per hour (mph) to Kilometers per hour (kmph). More...
 
float mm2inch (float mm)
 Convert millimeters (mm) to inches (inch). More...
 
float inch2mm (float inch)
 Convert inches (inch) to millimeters (mm). More...
 
float kpa2psi (float kpa)
 Convert kilo Pascal (kPa) to pounds per square inch (PSI). More...
 
float psi2kpa (float psi)
 Convert pounds per square inch (PSI) to kilo Pascal (kPa). More...
 
float hpa2inhg (float hpa)
 Convert hecto Pascal (hPa) to inches of mercury (inHg). More...
 
float inhg2hpa (float inhg)
 Convert inches of mercury (inHg) to hecto Pascal (hPa). More...
 
bool str_endswith (const char *restrict str, const char *restrict suffix)
 Return true if the string ends with the specified suffix, otherwise return false. More...
 
char * str_replace (char *orig, char *rep, char *with)
 Replace a pattern in a string. More...
 
const char * nice_freq (double freq)
 Make a nice printable string for a frequency. More...
 

Detailed Description

Various utility functions for use by applications.

Copyright (C) 2015 Tommy Vestermark

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Function Documentation

◆ celsius2fahrenheit()

float celsius2fahrenheit ( float  celsius)

Convert Celsius to Fahrenheit.

Parameters
celsiustemperature in Celsius
Returns
temperature value in Fahrenheit

Referenced by data_acquired_handler().

◆ fahrenheit2celsius()

float fahrenheit2celsius ( float  fahrenheit)

Convert Fahrenheit to Celsius.

Parameters
celsiustemperature in Fahrenheit
Returns
temperature value in Celsius

Referenced by data_acquired_handler().

◆ format_time_str()

char* format_time_str ( char *  buf,
char const *  format,
time_t  time_secs 
)

Printable timestamp in local time.

Parameters
buf[out]output buffer, long enough for "YYYY-MM-DD HH:MM:SS"
formattime format string, uses "%Y-%m-%d %H:%M:%S" if NULL
time_secs0 for now, or seconds since the epoch
Returns
buf pointer (for short hand use as operator)

Referenced by pulse_data_print_pulse_header(), pulse_data_print_vcd_header(), and time_pos_str().

◆ get_time_now()

void get_time_now ( struct timeval tv)

Get current time with usec precision.

Parameters
tvoutput for current time

References gettimeofday().

Referenced by sdr_callback(), and usecs_time_str().

◆ hpa2inhg()

float hpa2inhg ( float  hpa)

Convert hecto Pascal (hPa) to inches of mercury (inHg).

Parameters
kpapressure in kPa
Returns
pressure in inHg

Referenced by data_acquired_handler().

◆ inch2mm()

float inch2mm ( float  inch)

Convert inches (inch) to millimeters (mm).

Parameters
inchmeasurement in inches
Returns
measurement in millimeters

Referenced by data_acquired_handler().

◆ inhg2hpa()

float inhg2hpa ( float  inhg)

Convert inches of mercury (inHg) to hecto Pascal (hPa).

Parameters
kpapressure in inHg
Returns
pressure in hPa

Referenced by data_acquired_handler().

◆ kmph2mph()

float kmph2mph ( float  kph)

Convert Kilometers per hour (kph) to Miles per hour (mph).

Parameters
kphspeed in Kilometers per hour
Returns
speed in miles per hour

Referenced by data_acquired_handler().

◆ kpa2psi()

float kpa2psi ( float  kpa)

Convert kilo Pascal (kPa) to pounds per square inch (PSI).

Parameters
kpapressure in kPa
Returns
pressure in PSI

Referenced by data_acquired_handler().

◆ mm2inch()

float mm2inch ( float  mm)

Convert millimeters (mm) to inches (inch).

Parameters
mmmeasurement in millimeters
Returns
measurement in inches

Referenced by data_acquired_handler().

◆ mph2kmph()

float mph2kmph ( float  kph)

Convert Miles per hour (mph) to Kilometers per hour (kmph).

Parameters
mphspeed in Kilometers per hour
Returns
speed in kilometers per hour

Referenced by data_acquired_handler().

◆ nice_freq()

const char* nice_freq ( double  freq)

Make a nice printable string for a frequency.

Parameters
freqthe frequency to convert to a string.

Referenced by pulse_data_print_vcd_header(), and sdr_set_center_freq().

◆ psi2kpa()

float psi2kpa ( float  psi)

Convert pounds per square inch (PSI) to kilo Pascal (kPa).

Parameters
psipressure in PSI
Returns
pressure in kPa

Referenced by data_acquired_handler().

◆ sample_pos_str()

char* sample_pos_str ( float  sample_file_pos,
char *  buf 
)

Printable sample position.

Parameters
sample_possample position
bufoutput buffer, long enough for "@0.000000s"
Returns
buf pointer (for short hand use as operator)

Referenced by time_pos_str().

◆ str_endswith()

bool str_endswith ( const char *restrict  str,
const char *restrict  suffix 
)

Return true if the string ends with the specified suffix, otherwise return false.

Parameters
strstring to search for patterns
suffixthe pattern to search
Returns
true if the string ends with the specified suffix, false otherwise.

References strlen().

Referenced by data_acquired_handler().

◆ str_replace()

char* str_replace ( char *  orig,
char *  rep,
char *  with 
)

Replace a pattern in a string.

This utility function is useful when converting native units to si or customary.

Parameters
origstring to search for patterns
repthe pattern to replace
withthe replacement pattern
Returns
a new string that has rep replaced with with

References strlen().

Referenced by data_acquired_handler().

◆ usecs_time_str()

char* usecs_time_str ( char *  buf,
char const *  format,
struct timeval tv 
)

Printable timestamp in local time with microseconds.

Parameters
buf[out]output buffer, long enough for "YYYY-MM-DD HH:MM:SS.uuuuuu"
formattime format string without usec, uses "%Y-%m-%d %H:%M:%S" if NULL
tvNULL for now, or seconds and microseconds since the epoch
Returns
buf pointer (for short hand use as operator)

References get_time_now(), timeval::tv_sec, and timeval::tv_usec.

Referenced by time_pos_str().