Harmonize Doxygen comments; enable Autobrief

This commit is contained in:
Christian W. Zuckschwerdt 2019-02-13 16:36:32 +01:00
parent dd842fc8af
commit baace97a5a
40 changed files with 764 additions and 738 deletions

View file

@ -177,7 +177,7 @@ SHORT_NAMES = NO
# description.) # description.)
# The default value is: NO. # The default value is: NO.
JAVADOC_AUTOBRIEF = NO JAVADOC_AUTOBRIEF = YES
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If # line (until the first dot) of a Qt-style comment as the brief description. If

View file

@ -1,13 +1,13 @@
/** /** @file
* array buffer (string builder). array buffer (string builder).
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_ABUF_H_ #ifndef INCLUDE_ABUF_H_
#define INCLUDE_ABUF_H_ #define INCLUDE_ABUF_H_

View file

@ -1,13 +1,13 @@
/** /** @file
* AM signal analyzer AM signal analyzer.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_AM_ANALYZE_H_ #ifndef INCLUDE_AM_ANALYZE_H_
#define INCLUDE_AM_ANALYZE_H_ #define INCLUDE_AM_ANALYZE_H_

View file

@ -1,28 +1,27 @@
/** /** @file
* Baseband Various functions for baseband sample processing.
*
* Various functions for baseband sample processing Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
* Copyright (C) 2015 Tommy Vestermark
* Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
* 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
* This program is free software; you can redistribute it and/or modify the Free Software Foundation; either version 2 of the License, or
* it under the terms of the GNU General Public License as published by (at your option) any later version.
* the Free Software Foundation; either version 2 of the License, or */
* (at your option) any later version.
*/
#ifndef INCLUDE_BASEBAND_H_ #ifndef INCLUDE_BASEBAND_H_
#define INCLUDE_BASEBAND_H_ #define INCLUDE_BASEBAND_H_
#include <stdint.h> #include <stdint.h>
/// This will give a noisy envelope of OOK/ASK signals /** This will give a noisy envelope of OOK/ASK signals.
/// Subtract the bias (-128) and get an envelope estimation (absolute squared) Subtract the bias (-128) and get an envelope estimation (absolute squared)
/// @param *iq_buf: input samples (I/Q samples in interleaved uint8) @param *iq_buf: input samples (I/Q samples in interleaved uint8)
/// @param *y_buf: output @param *y_buf: output
/// @param len: number of samples to process @param len: number of samples to process
*/
void envelope_detect(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len); void envelope_detect(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len);
// for evaluation // for evaluation
@ -34,41 +33,44 @@ void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len);
#define FILTER_ORDER 1 #define FILTER_ORDER 1
/// Filter state buffer /// Filter state buffer.
typedef struct { typedef struct {
int16_t y[FILTER_ORDER]; int16_t y[FILTER_ORDER];
int16_t x[FILTER_ORDER]; int16_t x[FILTER_ORDER];
} FilterState; } FilterState;
/// FM_Demod state buffer /// FM_Demod state buffer.
typedef struct { typedef struct {
int32_t br, bi; // Last I/Q sample int32_t br, bi; // Last I/Q sample
int32_t xlp, ylp; // Low-pass filter state int32_t xlp, ylp; // Low-pass filter state
} DemodFM_State; } DemodFM_State;
/// Lowpass filter /** Lowpass filter.
///
/// Function is stateful Function is stateful
/// @param *x_buf: input samples to be filtered @param *x_buf: input samples to be filtered
/// @param *y_buf: output from filter @param *y_buf: output from filter
/// @param len: number of samples to process @param len: number of samples to process
/// @param FilterState: State to store between chunk processing @param FilterState: State to store between chunk processing
*/
void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state); void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state);
/// FM demodulator /** FM demodulator.
///
/// Function is stateful Function is stateful
/// @param *x_buf: input samples (I/Q samples in interleaved uint8) @param *x_buf: input samples (I/Q samples in interleaved uint8)
/// @param *y_buf: output from FM demodulator @param *y_buf: output from FM demodulator
/// @param len: number of samples to process @param len: number of samples to process
/// @param DemodFM_State: State to store between chunk processing @param DemodFM_State: State to store between chunk processing
*/
void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state); void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state);
// for evaluation /// For evaluation.
void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state); void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state);
/// Initialize tables and constants /** Initialize tables and constants.
/// Should be called once at startup Should be called once at startup.
*/
void baseband_init(void); void baseband_init(void);
#endif /* INCLUDE_BASEBAND_H_ */ #endif /* INCLUDE_BASEBAND_H_ */

View file

@ -1,14 +1,13 @@
/** /** @file
* Bit buffer A two-dimensional bit buffer consisting of bytes.
*
* A two-dimensional bit buffer consisting of bytes Copyright (C) 2015 Tommy Vestermark
*
* Copyright (C) 2015 Tommy Vestermark This program is free software; you can redistribute it and/or modify
* 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
* it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
* (at your option) any later version. */
*/
#ifndef INCLUDE_BITBUFFER_H_ #ifndef INCLUDE_BITBUFFER_H_
#define INCLUDE_BITBUFFER_H_ #define INCLUDE_BITBUFFER_H_
@ -22,7 +21,7 @@
typedef uint8_t bitrow_t[BITBUF_COLS]; typedef uint8_t bitrow_t[BITBUF_COLS];
typedef bitrow_t bitarray_t[BITBUF_ROWS]; typedef bitrow_t bitarray_t[BITBUF_ROWS];
/// Bit buffer /// Bit buffer.
typedef struct bitbuffer { typedef struct bitbuffer {
uint16_t num_rows; // Number of active rows uint16_t num_rows; // Number of active rows
uint16_t bits_per_row[BITBUF_ROWS]; // Number of active bits per row uint16_t bits_per_row[BITBUF_ROWS]; // Number of active bits per row
@ -30,73 +29,74 @@ typedef struct bitbuffer {
bitarray_t bb; // The actual bits buffer bitarray_t bb; // The actual bits buffer
} bitbuffer_t; } bitbuffer_t;
/// Clear the content of the bitbuffer /// Clear the content of the bitbuffer.
void bitbuffer_clear(bitbuffer_t *bits); void bitbuffer_clear(bitbuffer_t *bits);
/// Add a single bit at the end of the bitbuffer (MSB first) /// Add a single bit at the end of the bitbuffer (MSB first).
void bitbuffer_add_bit(bitbuffer_t *bits, int bit); void bitbuffer_add_bit(bitbuffer_t *bits, int bit);
/// Add a new row to the bitbuffer /// Add a new row to the bitbuffer.
void bitbuffer_add_row(bitbuffer_t *bits); void bitbuffer_add_row(bitbuffer_t *bits);
/// Increment sync counter, add new row if not empty /// Increment sync counter, add new row if not empty.
void bitbuffer_add_sync(bitbuffer_t *bits); void bitbuffer_add_sync(bitbuffer_t *bits);
/// Extract (potentially unaligned) bytes from the bit buffer. Len is bits. /// Extract (potentially unaligned) bytes from the bit buffer. Len is bits.
void bitbuffer_extract_bytes(bitbuffer_t *bitbuffer, unsigned row, void bitbuffer_extract_bytes(bitbuffer_t *bitbuffer, unsigned row,
unsigned pos, uint8_t *out, unsigned len); unsigned pos, uint8_t *out, unsigned len);
/// Invert all bits in the bitbuffer (do not invert the empty bits) /// Invert all bits in the bitbuffer (do not invert the empty bits).
void bitbuffer_invert(bitbuffer_t *bits); void bitbuffer_invert(bitbuffer_t *bits);
// Non-Return-to-Zero Space (NRZI) decode the bitbuffer. /// Non-Return-to-Zero Space (NRZI) decode the bitbuffer.
// "One" is represented by no change in level, "Zero" is represented by change in level. /// "One" is represented by no change in level, "Zero" is represented by change in level.
void bitbuffer_nrzs_decode(bitbuffer_t *bits); void bitbuffer_nrzs_decode(bitbuffer_t *bits);
// Non-Return-to-Zero Mark (NRZI) decode the bitbuffer. /// Non-Return-to-Zero Mark (NRZI) decode the bitbuffer.
// "One" is represented by change in level, "Zero" is represented by no change in level. /// "One" is represented by change in level, "Zero" is represented by no change in level.
void bitbuffer_nrzm_decode(bitbuffer_t *bits); void bitbuffer_nrzm_decode(bitbuffer_t *bits);
/// Print the content of the bitbuffer /// Print the content of the bitbuffer.
void bitbuffer_print(const bitbuffer_t *bits); void bitbuffer_print(const bitbuffer_t *bits);
/// Debug the content of the bitbuffer /// Debug the content of the bitbuffer.
void bitbuffer_debug(const bitbuffer_t *bits); void bitbuffer_debug(const bitbuffer_t *bits);
/// Print the content of a bit row (byte buffer) /// Print the content of a bit row (byte buffer).
void bitrow_print(bitrow_t const bitrow, unsigned bit_len); void bitrow_print(bitrow_t const bitrow, unsigned bit_len);
/// Debug the content of a bit row (byte buffer) /// Debug the content of a bit row (byte buffer).
void bitrow_debug(bitrow_t const bitrow, unsigned bit_len); void bitrow_debug(bitrow_t const bitrow, unsigned bit_len);
/// Parse a string into a bitbuffer /// Parse a string into a bitbuffer.
void bitbuffer_parse(bitbuffer_t *bits, const char *code); void bitbuffer_parse(bitbuffer_t *bits, const char *code);
// Search the specified row of the bitbuffer, starting from bit 'start', for /// Search the specified row of the bitbuffer, starting from bit 'start', for
// the pattern provided. Return the location of the first match, or the end /// the pattern provided. Return the location of the first match, or the end
// of the row if no match is found. /// of the row if no match is found.
// The pattern starts in the high bit. For example if searching for 011011 /// The pattern starts in the high bit. For example if searching for 011011
// the byte pointed to by 'pattern' would be 0xAC. (011011xx). /// the byte pointed to by 'pattern' would be 0xAC. (011011xx).
unsigned bitbuffer_search(bitbuffer_t *bitbuffer, unsigned row, unsigned start, unsigned bitbuffer_search(bitbuffer_t *bitbuffer, unsigned row, unsigned start,
const uint8_t *pattern, unsigned pattern_bits_len); const uint8_t *pattern, unsigned pattern_bits_len);
// Manchester decoding from one bitbuffer into another, starting at the /// Manchester decoding from one bitbuffer into another, starting at the
// specified row and start bit. Decode at most 'max' data bits (i.e. 2*max) /// specified row and start bit. Decode at most 'max' data bits (i.e. 2*max)
// bits from the input buffer). Return the bit position in the input row /// bits from the input buffer). Return the bit position in the input row
// (i.e. returns start + 2*outbuf->bits_per_row[0]). /// (i.e. returns start + 2*outbuf->bits_per_row[0]).
// per IEEE 802.3 conventions, i.e. high-low is a 0 bit, low-high is a 1 bit. /// per IEEE 802.3 conventions, i.e. high-low is a 0 bit, low-high is a 1 bit.
unsigned bitbuffer_manchester_decode(bitbuffer_t *inbuf, unsigned row, unsigned start, unsigned bitbuffer_manchester_decode(bitbuffer_t *inbuf, unsigned row, unsigned start,
bitbuffer_t *outbuf, unsigned max); bitbuffer_t *outbuf, unsigned max);
// Differential Manchester decoding from one bitbuffer into another, starting at the /// Differential Manchester decoding from one bitbuffer into another, starting at the
// specified row and start bit. Decode at most 'max' data bits (i.e. 2*max) /// specified row and start bit. Decode at most 'max' data bits (i.e. 2*max)
// bits from the input buffer). Return the bit position in the input row /// bits from the input buffer). Return the bit position in the input row
// (i.e. returns start + 2*outbuf->bits_per_row[0]). /// (i.e. returns start + 2*outbuf->bits_per_row[0]).
unsigned bitbuffer_differential_manchester_decode(bitbuffer_t *inbuf, unsigned row, unsigned start, unsigned bitbuffer_differential_manchester_decode(bitbuffer_t *inbuf, unsigned row, unsigned start,
bitbuffer_t *outbuf, unsigned max); bitbuffer_t *outbuf, unsigned max);
// Function to compare bitbuffer rows and count repetitions /// Function to compare bitbuffer rows and count repetitions.
int compare_rows(bitbuffer_t *bits, unsigned row_a, unsigned row_b); int compare_rows(bitbuffer_t *bits, unsigned row_a, unsigned row_b);
unsigned count_repeats(bitbuffer_t *bits, unsigned row); unsigned count_repeats(bitbuffer_t *bits, unsigned row);
/// Find a repeated row that has a minimum count of bits. /// Find a repeated row that has a minimum count of bits.
@ -104,13 +104,13 @@ unsigned count_repeats(bitbuffer_t *bits, unsigned row);
int bitbuffer_find_repeated_row(bitbuffer_t *bits, unsigned min_repeats, unsigned min_bits); int bitbuffer_find_repeated_row(bitbuffer_t *bits, unsigned min_repeats, unsigned min_bits);
/// Return a single bit from a bitrow at bit_idx position /// Return a single bit from a bitrow at bit_idx position.
static inline uint8_t bitrow_get_bit(const bitrow_t bitrow, unsigned bit_idx) static inline uint8_t bitrow_get_bit(const bitrow_t bitrow, unsigned bit_idx)
{ {
return bitrow[bit_idx >> 3] >> (7 - (bit_idx & 7)) & 1; return bitrow[bit_idx >> 3] >> (7 - (bit_idx & 7)) & 1;
} }
/// Return a single byte from a bitrow at bit_idx position (which may be unaligned) /// Return a single byte from a bitrow at bit_idx position (which may be unaligned).
static inline uint8_t bitrow_get_byte(const bitrow_t bitrow, unsigned bit_idx) static inline uint8_t bitrow_get_byte(const bitrow_t bitrow, unsigned bit_idx)
{ {
return ((bitrow[(bit_idx >> 3)] << (bit_idx & 7)) | return ((bitrow[(bit_idx >> 3)] << (bit_idx & 7)) |

View file

@ -1,12 +1,15 @@
// compat_paths addresses following compatibility issue: /** @file
// topic: default search paths for config file compat_paths addresses compatibility with default OS path names.
// issue: Linux and Windows use different common paths for config files
// solution: provide specific default paths for each system topic: default search paths for config file
issue: Linux and Windows use different common paths for config files
solution: provide specific default paths for each system
*/
#ifndef INCLUDE_COMPAT_PATHS_H_ #ifndef INCLUDE_COMPAT_PATHS_H_
#define INCLUDE_COMPAT_PATHS_H_ #define INCLUDE_COMPAT_PATHS_H_
/// get default search paths for rtl_433 config file /// Get default search paths for rtl_433 config file.
char **compat_get_default_conf_paths(void); char **compat_get_default_conf_paths(void);
#endif /* INCLUDE_COMPAT_PATHS_H_ */ #endif /* INCLUDE_COMPAT_PATHS_H_ */

View file

@ -1,7 +1,10 @@
// compat_time addresses following compatibility issue: /** @file
// topic: high-resolution timestamps compat_time addresses compatibility time functions.
// issue: <sys/time.h> is not available on Windows systems
// solution: provide a compatible version for Windows systems topic: high-resolution timestamps
issue: <sys/time.h> is not available on Windows systems
solution: provide a compatible version for Windows systems
*/
#ifndef INCLUDE_COMPAT_TIME_H_ #ifndef INCLUDE_COMPAT_TIME_H_
#define INCLUDE_COMPAT_TIME_H_ #define INCLUDE_COMPAT_TIME_H_

View file

@ -1,13 +1,13 @@
/** /** @file
* Light-weight (i.e. dumb) config-file parser Light-weight (i.e. dumb) config-file parser.
*
* Copyright (C) 2018 Christian W. Zuckschwerdt <zany@triq.net> Copyright (C) 2018 Christian W. Zuckschwerdt <zany@triq.net>
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_CONFPARSE_H_ #ifndef INCLUDE_CONFPARSE_H_
#define INCLUDE_CONFPARSE_H_ #define INCLUDE_CONFPARSE_H_
@ -17,22 +17,27 @@ struct conf_keywords {
int key; int key;
}; };
/// Check if a file exists and can be read. /** Check if a file exists and can be read.
/// @param path input file name
/// @return 1 if the file exists and is readable, 0 otherwise @param path input file name
@return 1 if the file exists and is readable, 0 otherwise
*/
int hasconf(char const *path); int hasconf(char const *path);
/// Open a config file, read contents to memory. /** Open a config file, read contents to memory.
/// @param path input file name
/// @return allocated memory containing the config file @param path input file name
@return allocated memory containing the config file
*/
char *readconf(char const *path); char *readconf(char const *path);
/// Return the next keyword token and set the optional argument. /** Return the next keyword token and set the optional argument.
///
/// @param conf current position in conf @param conf current position in conf
/// @param keywords list of possible keywords @param keywords list of possible keywords
/// @param arg optional out pointer to a argument string @param arg optional out pointer to a argument string
/// @return the next keyword token, -1 otherwise. @return the next keyword token, -1 otherwise.
*/
int getconf(char **conf, struct conf_keywords const keywords[], char **arg); int getconf(char **conf, struct conf_keywords const keywords[], char **arg);
#endif /* INCLUDE_CONFPARSE_H_ */ #endif /* INCLUDE_CONFPARSE_H_ */

View file

@ -1,22 +1,22 @@
/* /** @file
* A general structure for extracting hierarchical data from the devices; A general structure for extracting hierarchical data from the devices;
* typically key-value pairs, but allows for more rich data as well. typically key-value pairs, but allows for more rich data as well.
*
* Copyright (C) 2015 by Erkki Seppälä <flux@modeemi.fi> Copyright (C) 2015 by Erkki Seppälä <flux@modeemi.fi>
*
* This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef INCLUDE_DATA_H_ #ifndef INCLUDE_DATA_H_
#define INCLUDE_DATA_H_ #define INCLUDE_DATA_H_
@ -35,7 +35,7 @@
// MSVC has something like C99 restrict as __restrict // MSVC has something like C99 restrict as __restrict
#ifndef restrict #ifndef restrict
#define restrict __restrict #define restrict __restrict
#endif #endif
#endif #endif
@ -52,13 +52,13 @@
#endif #endif
typedef enum { typedef enum {
DATA_DATA, /* pointer to data is stored */ DATA_DATA, /**< pointer to data is stored */
DATA_INT, /* pointer to integer is stored */ DATA_INT, /**< pointer to integer is stored */
DATA_DOUBLE, /* pointer to a double is stored */ DATA_DOUBLE, /**< pointer to a double is stored */
DATA_STRING, /* pointer to a string is stored */ DATA_STRING, /**< pointer to a string is stored */
DATA_ARRAY, /* pointer to an array of values is stored */ DATA_ARRAY, /**< pointer to an array of values is stored */
DATA_COUNT, /* invalid */ DATA_COUNT, /**< invalid */
DATA_FORMAT /* indicates the following value is formatted */ DATA_FORMAT /**< indicates the following value is formatted */
} data_type_t; } data_type_t;
typedef struct data_array { typedef struct data_array {
@ -69,12 +69,12 @@ typedef struct data_array {
typedef struct data { typedef struct data {
char *key; char *key;
char *pretty_key; /* the name used for displaying data to user in with a nicer name */ char *pretty_key; /**< the name used for displaying data to user in with a nicer name */
data_type_t type; data_type_t type;
char *format; /* if not null, contains special formatting string */ char *format; /**< if not null, contains special formatting string */
void *value; void *value;
unsigned retain; /* incremented on data_retain, data_free only frees if this is zero */ unsigned retain; /**< incremented on data_retain, data_free only frees if this is zero */
struct data *next; /* chaining to the next element in the linked list; NULL indicates end-of-list */ struct data *next; /**< chaining to the next element in the linked list; NULL indicates end-of-list */
} data_t; } data_t;
/** Constructs a structured data object. /** Constructs a structured data object.
@ -132,7 +132,7 @@ data_t *data_prepend(data_t *first, const char *key, const char *pretty_key, ...
*/ */
data_array_t *data_array(int num_values, data_type_t type, void *ptr); data_array_t *data_array(int num_values, data_type_t type, void *ptr);
/** Releases a data array */ /** Releases a data array. */
void data_array_free(data_array_t *array); void data_array_free(data_array_t *array);
/** Retain a structure object, returns the structure object passed in. */ /** Retain a structure object, returns the structure object passed in. */
@ -155,7 +155,7 @@ typedef struct data_output {
FILE *file; FILE *file;
} data_output_t; } data_output_t;
/** Construct data output for CSV printer /** Construct data output for CSV printer.
@param file the output stream @param file the output stream
@return The auxiliary data to pass along with data_csv_printer to data_print. @return The auxiliary data to pass along with data_csv_printer to data_print.
@ -178,10 +178,10 @@ struct data_output *data_output_syslog_create(const char *host, const char *port
*/ */
void data_output_start(struct data_output *output, const char **fields, int num_fields); void data_output_start(struct data_output *output, const char **fields, int num_fields);
/** Prints a structured data object */ /** Prints a structured data object. */
void data_output_print(struct data_output *output, data_t *data); void data_output_print(struct data_output *output, data_t *data);
/** Allows to polls an event loop, if necessary */ /** Allows to polls an event loop, if necessary. */
void data_output_poll(struct data_output *output); void data_output_poll(struct data_output *output);
void data_output_free(struct data_output *output); void data_output_free(struct data_output *output);

View file

@ -1,3 +1,7 @@
/** @file
Meta include for all decoders.
*/
#ifndef INCLUDE_DECODER_H_ #ifndef INCLUDE_DECODER_H_
#define INCLUDE_DECODER_H_ #define INCLUDE_DECODER_H_

View file

@ -1,13 +1,13 @@
/** /** @file
* High-level utility functions for decoders High-level utility functions for decoders.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_DECODER_UTIL_H_ #ifndef INCLUDE_DECODER_UTIL_H_
#define INCLUDE_DECODER_UTIL_H_ #define INCLUDE_DECODER_UTIL_H_

View file

@ -1,13 +1,13 @@
/** /** @file
* Various utility functions handling file formats Various utility functions handling file formats.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_FILEFORMAT_H_ #ifndef INCLUDE_FILEFORMAT_H_
#define INCLUDE_FILEFORMAT_H_ #define INCLUDE_FILEFORMAT_H_
@ -17,8 +17,8 @@
char const *file_basename(char const *path); char const *file_basename(char const *path);
// a single handy number to define the file type. /// a single handy number to define the file type.
// bitmask: RRRR LLLL WWWWWWWW 00CC 00FS /// bitmask: RRRR LLLL WWWWWWWW 00CC 00FS
enum file_type { enum file_type {
// format bits // format bits
F_UNSIGNED = 0 << 0, F_UNSIGNED = 0 << 0,

View file

@ -1,13 +1,13 @@
/** /** @file
* Generic list Generic list.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stddef.h> #include <stddef.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* Option parsing functions to complement getopt. Option parsing functions to complement getopt.
*
* Copyright (C) 2017 Christian Zuckschwerdt Copyright (C) 2017 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_OPTPARSE_H_ #ifndef INCLUDE_OPTPARSE_H_
#define INCLUDE_OPTPARSE_H_ #define INCLUDE_OPTPARSE_H_
@ -52,7 +52,7 @@ int atoi_time(const char *str, const char *error_hint);
/// @return the original value of *stringp /// @return the original value of *stringp
char *asepc(char **stringp, char delim); char *asepc(char **stringp, char delim);
/// Parse a comma-separated list of key/value pairs into kwargs /// Parse a comma-separated list of key/value pairs into kwargs.
/// ///
/// The input string will be modified and the pointer advanced. /// The input string will be modified and the pointer advanced.
/// The key and val pointers will be into the original string. /// The key and val pointers will be into the original string.

View file

@ -1,14 +1,15 @@
/** /** @file
* Pulse demodulation functions Pulse demodulation functions.
*
* Binary demodulators (PWM/PPM/Manchester/...) using a pulse data structure as input Binary demodulators (PWM/PPM/Manchester/...) using a pulse data structure as input
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#ifndef INCLUDE_PULSE_DEMOD_H_ #ifndef INCLUDE_PULSE_DEMOD_H_
#define INCLUDE_PULSE_DEMOD_H_ #define INCLUDE_PULSE_DEMOD_H_
@ -16,8 +17,7 @@
#include "pulse_detect.h" #include "pulse_detect.h"
#include "rtl_433_devices.h" #include "rtl_433_devices.h"
/// Demodulate a Pulse Code Modulation signal.
/// Demodulate a Pulse Code Modulation signal
/// ///
/// Demodulate a Pulse Code Modulation (PCM) signal where bit width /// Demodulate a Pulse Code Modulation (PCM) signal where bit width
/// is fixed and each bit starts with a pulse or not. It may be either /// is fixed and each bit starts with a pulse or not. It may be either
@ -32,8 +32,7 @@
/// @return number of events processed /// @return number of events processed
int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device); int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device);
/// Demodulate a Pulse Position Modulation signal.
/// Demodulate a Pulse Position Modulation signal
/// ///
/// Demodulate a Pulse Position Modulation (PPM) signal consisting of pulses with variable gap. /// Demodulate a Pulse Position Modulation (PPM) signal consisting of pulses with variable gap.
/// Pulse width may be fixed or variable. /// Pulse width may be fixed or variable.
@ -48,8 +47,7 @@ int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device);
/// @return number of events processed /// @return number of events processed
int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device); int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device);
/// Demodulate a Pulse Width Modulation signal.
/// Demodulate a Pulse Width Modulation signal
/// ///
/// Demodulate a Pulse Width Modulation (PWM) signal consisting of short, long, and optional sync pulses. /// Demodulate a Pulse Width Modulation (PWM) signal consisting of short, long, and optional sync pulses.
/// Gap between pulses may be of fixed size or variable (e.g. fixed period) /// Gap between pulses may be of fixed size or variable (e.g. fixed period)
@ -65,8 +63,7 @@ int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device);
/// @return number of events processed /// @return number of events processed
int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device); int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device);
/// Demodulate a Manchester encoded signal with a hardcoded zerobit in front.
/// Demodulate a Manchester encoded signal with a hardcoded zerobit in front
/// ///
/// Demodulate a Manchester encoded signal where first rising edge is counted as a databit /// Demodulate a Manchester encoded signal where first rising edge is counted as a databit
/// and therefore always will be zero (Most likely a hardcoded Oregon Scientific peculiarity) /// and therefore always will be zero (Most likely a hardcoded Oregon Scientific peculiarity)
@ -81,8 +78,7 @@ int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device);
/// @return number of events processed /// @return number of events processed
int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device); int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device);
/// Demodulate a Differential Manchester Coded signal.
/// Demodulate a Differential Manchester Coded signal
/// ///
/// No level shift within the clock cycle translates to a logic 0 /// No level shift within the clock cycle translates to a logic 0
/// One level shift within the clock cycle translates to a logic 1 /// One level shift within the clock cycle translates to a logic 1
@ -103,8 +99,7 @@ int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
/// @return number of events processed /// @return number of events processed
int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device); int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device);
/// Demodulate a raw Pulse Interval and Width Modulation signal.
/// Demodulate a raw Pulse Interval and Width Modulation signal
/// ///
/// Each level shift is a new bit. /// Each level shift is a new bit.
/// A short interval is a logic 1, a long interval a logic 0 /// A short interval is a logic 1, a long interval a logic 0
@ -116,8 +111,7 @@ int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device);
/// @return number of events processed /// @return number of events processed
int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device); int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device);
/// Demodulate a differential Pulse Interval and Width Modulation signal.
/// Demodulate a differential Pulse Interval and Width Modulation signal
/// ///
/// Each level shift is a new bit. /// Each level shift is a new bit.
/// A short interval is a logic 1, a long interval a logic 0 /// A short interval is a logic 1, a long interval a logic 0
@ -129,11 +123,9 @@ int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device);
/// @return number of events processed /// @return number of events processed
int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device); int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device);
int pulse_demod_osv1(const pulse_data_t *pulses, r_device *device); int pulse_demod_osv1(const pulse_data_t *pulses, r_device *device);
/// Simulate demodulation using a given signal code string.
/// Simulate demodulation using a given signal code string
/// ///
/// The (optionally "0x" prefixed) hex code is processed into a bitbuffer_t. /// The (optionally "0x" prefixed) hex code is processed into a bitbuffer_t.
/// Each row is optionally prefixed with a length enclosed in braces "{}" or /// Each row is optionally prefixed with a length enclosed in braces "{}" or

View file

@ -1,12 +1,13 @@
/** /** @file
* Pulse detection functions Pulse detection functions.
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#ifndef INCLUDE_PULSE_DETECT_H_ #ifndef INCLUDE_PULSE_DETECT_H_
#define INCLUDE_PULSE_DETECT_H_ #define INCLUDE_PULSE_DETECT_H_
@ -15,27 +16,27 @@
#include <stdio.h> #include <stdio.h>
#include "r_util.h" #include "r_util.h"
#define PD_MAX_PULSES 1200 // Maximum number of pulses before forcing End Of Package #define PD_MAX_PULSES 1200 // Maximum number of pulses before forcing End Of Package
#define PD_MIN_PULSES 16 // Minimum number of pulses before declaring a proper package #define PD_MIN_PULSES 16 // Minimum number of pulses before declaring a proper package
#define PD_MIN_PULSE_SAMPLES 10 // Minimum number of samples in a pulse for proper detection #define PD_MIN_PULSE_SAMPLES 10 // Minimum number of samples in a pulse for proper detection
#define PD_MIN_GAP_MS 10 // Minimum gap size in milliseconds to exceed to declare End Of Package #define PD_MIN_GAP_MS 10 // Minimum gap size in milliseconds to exceed to declare End Of Package
#define PD_MAX_GAP_MS 100 // Maximum gap size in milliseconds to exceed to declare End Of Package #define PD_MAX_GAP_MS 100 // Maximum gap size in milliseconds to exceed to declare End Of Package
#define PD_MAX_GAP_RATIO 10 // Ratio gap/pulse width to exceed to declare End Of Package (heuristic) #define PD_MAX_GAP_RATIO 10 // Ratio gap/pulse width to exceed to declare End Of Package (heuristic)
#define PD_MAX_PULSE_MS 100 // Pulse width in ms to exceed to declare End Of Package (e.g. for non OOK packages) #define PD_MAX_PULSE_MS 100 // Pulse width in ms to exceed to declare End Of Package (e.g. for non OOK packages)
/// Data for a compact representation of generic pulse train /// Data for a compact representation of generic pulse train.
typedef struct { typedef struct {
uint64_t offset; // Offset to first pulse in number of samples from start of stream uint64_t offset; ///< Offset to first pulse in number of samples from start of stream.
uint32_t sample_rate; // Sample rate the pulses are recorded with. uint32_t sample_rate; ///< Sample rate the pulses are recorded with.
unsigned start_ago; // Start of first pulse in number of samples ago unsigned start_ago; ///< Start of first pulse in number of samples ago.
unsigned end_ago; // End of last pulse in number of samples ago unsigned end_ago; ///< End of last pulse in number of samples ago.
unsigned int num_pulses; unsigned int num_pulses;
int pulse[PD_MAX_PULSES]; // Width of pulses (high) in number of samples int pulse[PD_MAX_PULSES]; ///< Width of pulses (high) in number of samples.
int gap[PD_MAX_PULSES]; // Width of gaps between pulses (low) in number of samples int gap[PD_MAX_PULSES]; ///< Width of gaps between pulses (low) in number of samples.
int ook_low_estimate; // Estimate for the OOK low level (base noise level) at beginning of package int ook_low_estimate; ///< Estimate for the OOK low level (base noise level) at beginning of package.
int ook_high_estimate; // Estimate for the OOK high level at end of package int ook_high_estimate; ///< Estimate for the OOK high level at end of package.
int fsk_f1_est; // Estimate for the F1 frequency for FSK int fsk_f1_est; ///< Estimate for the F1 frequency for FSK.
int fsk_f2_est; // Estimate for the F2 frequency for FSK int fsk_f2_est; ///< Estimate for the F2 frequency for FSK.
float freq1_hz; float freq1_hz;
float freq2_hz; float freq2_hz;
float rssi_db; float rssi_db;
@ -45,37 +46,37 @@ typedef struct {
typedef struct pulse_detect pulse_detect_t; typedef struct pulse_detect pulse_detect_t;
/// Clear the content of a pulse_data_t structure /// Clear the content of a pulse_data_t structure.
void pulse_data_clear(pulse_data_t *data); // Clear the struct void pulse_data_clear(pulse_data_t *data);
/// Print the content of a pulse_data_t structure (for debug) /// Print the content of a pulse_data_t structure (for debug).
void pulse_data_print(pulse_data_t const *data); void pulse_data_print(pulse_data_t const *data);
/// Dump the content of a pulse_data_t structure as raw binary /// Dump the content of a pulse_data_t structure as raw binary.
void pulse_data_dump_raw(uint8_t *buf, unsigned len, uint64_t buf_offset, pulse_data_t const *data, uint8_t bits); void pulse_data_dump_raw(uint8_t *buf, unsigned len, uint64_t buf_offset, pulse_data_t const *data, uint8_t bits);
/// Print a header for the VCD format /// Print a header for the VCD format.
void pulse_data_print_vcd_header(FILE *file, uint32_t sample_rate); void pulse_data_print_vcd_header(FILE *file, uint32_t sample_rate);
/// Print the content of a pulse_data_t structure in VCD format /// Print the content of a pulse_data_t structure in VCD format.
void pulse_data_print_vcd(FILE *file, pulse_data_t const *data, int ch_id); void pulse_data_print_vcd(FILE *file, pulse_data_t const *data, int ch_id);
/// Read the next pulse_data_t structure from OOK text /// Read the next pulse_data_t structure from OOK text.
void pulse_data_load(FILE *file, pulse_data_t *data); void pulse_data_load(FILE *file, pulse_data_t *data);
/// Print a header for the OOK text format /// Print a header for the OOK text format.
void pulse_data_print_pulse_header(FILE *file); void pulse_data_print_pulse_header(FILE *file);
/// Print the content of a pulse_data_t structure as OOK text /// Print the content of a pulse_data_t structure as OOK text.
void pulse_data_dump(FILE *file, pulse_data_t *data); void pulse_data_dump(FILE *file, pulse_data_t *data);
pulse_detect_t *pulse_detect_create(void); pulse_detect_t *pulse_detect_create(void);
void pulse_detect_free(pulse_detect_t *pulse_detect); void pulse_detect_free(pulse_detect_t *pulse_detect);
/// Demodulate On/Off Keying (OOK) and Frequency Shift Keying (FSK) from an envelope signal /// Demodulate On/Off Keying (OOK) and Frequency Shift Keying (FSK) from an envelope signal.
/// ///
/// Function is stateful and can be called with chunks of input data /// Function is stateful and can be called with chunks of input data.
/// @param envelope_data: Samples with amplitude envelope of carrier /// @param envelope_data: Samples with amplitude envelope of carrier
/// @param fm_data: Samples with frequency offset from center frequency /// @param fm_data: Samples with frequency offset from center frequency
/// @param len: Number of samples in input buffers /// @param len: Number of samples in input buffers
@ -87,7 +88,7 @@ void pulse_detect_free(pulse_detect_t *pulse_detect);
/// @return 2 if FSK package is detected (but all sample data is still not completely processed) /// @return 2 if FSK package is detected (but all sample data is still not completely processed)
int pulse_detect_package(pulse_detect_t *pulse_detect, int16_t const *envelope_data, int16_t const *fm_data, int len, int16_t level_limit, uint32_t samp_rate, uint64_t sample_offset, pulse_data_t *pulses, pulse_data_t *fsk_pulses); int pulse_detect_package(pulse_detect_t *pulse_detect, int16_t const *envelope_data, int16_t const *fm_data, int len, int16_t level_limit, uint32_t samp_rate, uint64_t sample_offset, pulse_data_t *pulses, pulse_data_t *fsk_pulses);
/// Analyze and print result /// Analyze and print result.
void pulse_analyzer(pulse_data_t *data); void pulse_analyzer(pulse_data_t *data);

View file

@ -1,12 +1,13 @@
/** /** @file
* Various utility functions for use by applications Various utility functions for use by applications.
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#ifndef INCLUDE_R_UTIL_H_ #ifndef INCLUDE_R_UTIL_H_
#define INCLUDE_R_UTIL_H_ #define INCLUDE_R_UTIL_H_
@ -19,124 +20,142 @@
#if defined _MSC_VER // Microsoft Visual Studio #if defined _MSC_VER // Microsoft Visual Studio
// MSC has something like C99 restrict as __restrict // MSC has something like C99 restrict as __restrict
#ifndef restrict #ifndef restrict
#define restrict __restrict #define restrict __restrict
#endif #endif
#endif #endif
// buffer to hold localized timestamp "YYYY-MM-DD HH:MM:SS.000000" // buffer to hold localized timestamp "YYYY-MM-DD HH:MM:SS.000000"
#define LOCAL_TIME_BUFLEN 32 #define LOCAL_TIME_BUFLEN 32
/// Get current time with usec precision. /** Get current time with usec precision.
///
/// @param tv: output for current time @param tv: output for current time
*/
void get_time_now(struct timeval *tv); void get_time_now(struct timeval *tv);
/// Printable timestamp in local time /** Printable timestamp in local time.
///
/// @param time_secs: 0 for now, or seconds since the epoch @param time_secs: 0 for now, or seconds since the epoch
/// @param buf: output buffer, long enough for "YYYY-MM-DD HH:MM:SS" @param buf: output buffer, long enough for "YYYY-MM-DD HH:MM:SS"
/// @return buf pointer (for short hand use as operator) @return buf pointer (for short hand use as operator)
*/
char* local_time_str(time_t time_secs, char *buf); char* local_time_str(time_t time_secs, char *buf);
/// Printable timestamp in local time with microseconds. /** Printable timestamp in local time with microseconds.
///
/// @param tv: NULL for now, or seconds and microseconds since the epoch @param tv: NULL for now, or seconds and microseconds since the epoch
/// @param buf: output buffer, long enough for "YYYY-MM-DD HH:MM:SS" @param buf: output buffer, long enough for "YYYY-MM-DD HH:MM:SS"
/// @return buf pointer (for short hand use as operator) @return buf pointer (for short hand use as operator)
*/
char *usecs_time_str(struct timeval *tv, char *buf); char *usecs_time_str(struct timeval *tv, char *buf);
/// Printable sample position /** Printable sample position.
///
/// @param sample_pos sample position @param sample_pos sample position
/// @param buf: output buffer, long enough for "@0.000000s" @param buf: output buffer, long enough for "@0.000000s"
/// @return buf pointer (for short hand use as operator) @return buf pointer (for short hand use as operator)
*/
char *sample_pos_str(float sample_file_pos, char *buf); char *sample_pos_str(float sample_file_pos, char *buf);
/// Convert Celsius to Fahrenheit /** Convert Celsius to Fahrenheit.
///
/// @param celsius: temperature in Celsius @param celsius: temperature in Celsius
/// @return temperature value in Fahrenheit @return temperature value in Fahrenheit
*/
float celsius2fahrenheit(float celsius); float celsius2fahrenheit(float celsius);
/// Convert Fahrenheit to Celsius /** Convert Fahrenheit to Celsius.
///
/// @param celsius: temperature in Fahrenheit @param celsius: temperature in Fahrenheit
/// @return temperature value in Celsius @return temperature value in Celsius
*/
float fahrenheit2celsius(float fahrenheit); float fahrenheit2celsius(float fahrenheit);
/// Convert Kilometers per hour (kph) to Miles per hour (mph) /** Convert Kilometers per hour (kph) to Miles per hour (mph).
///
/// @param kph: speed in Kilometers per hour @param kph: speed in Kilometers per hour
/// @return speed in miles per hour @return speed in miles per hour
*/
float kmph2mph(float kph); float kmph2mph(float kph);
/// Convert Miles per hour (mph) to Kilometers per hour (kmph) /** Convert Miles per hour (mph) to Kilometers per hour (kmph).
///
/// @param mph: speed in Kilometers per hour @param mph: speed in Kilometers per hour
/// @return speed in kilometers per hour @return speed in kilometers per hour
*/
float mph2kmph(float kph); float mph2kmph(float kph);
/// Convert millimeters (mm) to inches (inch) /** Convert millimeters (mm) to inches (inch).
///
/// @param mm: measurement in millimeters @param mm: measurement in millimeters
/// @return measurement in inches @return measurement in inches
*/
float mm2inch(float mm); float mm2inch(float mm);
/// Convert inches (inch) to millimeters (mm) /** Convert inches (inch) to millimeters (mm).
///
/// @param inch: measurement in inches @param inch: measurement in inches
/// @return measurement in millimeters @return measurement in millimeters
*/
float inch2mm(float inch); float inch2mm(float inch);
/// Convert kilo Pascal (kPa) to pounds per square inch (PSI) /** Convert kilo Pascal (kPa) to pounds per square inch (PSI).
///
/// @param kpa: pressure in kPa @param kpa: pressure in kPa
/// @return pressure in PSI @return pressure in PSI
*/
float kpa2psi(float kpa); float kpa2psi(float kpa);
/// Convert pounds per square inch (PSI) to kilo Pascal (kPa) /** Convert pounds per square inch (PSI) to kilo Pascal (kPa).
///
/// @param psi: pressure in PSI @param psi: pressure in PSI
/// @return pressure in kPa @return pressure in kPa
*/
float psi2kpa(float psi); float psi2kpa(float psi);
/// Convert hecto Pascal (hPa) to inches of mercury (inHg) /** Convert hecto Pascal (hPa) to inches of mercury (inHg).
///
/// @param kpa: pressure in kPa @param kpa: pressure in kPa
/// @return pressure in inHg @return pressure in inHg
*/
float hpa2inhg(float hpa); float hpa2inhg(float hpa);
/// Convert inches of mercury (inHg) to hecto Pascal (hPa) /** Convert inches of mercury (inHg) to hecto Pascal (hPa).
///
/// @param kpa: pressure in inHg @param kpa: pressure in inHg
/// @return pressure in hPa @return pressure in hPa
*/
float inhg2hpa(float inhg); float inhg2hpa(float inhg);
/// Return true if the string ends with the specified suffix, otherwise return false. /** Return true if the string ends with the specified suffix, otherwise return false.
///
/// @param str: string to search for patterns @param str: string to search for patterns
/// @param suffix: the pattern to search @param suffix: the pattern to search
/// @return true if the string ends with the specified suffix, false otherwise. @return true if the string ends with the specified suffix, false otherwise.
*/
bool str_endswith(const char *restrict str, const char *restrict suffix); bool str_endswith(const char *restrict str, const char *restrict suffix);
/// Replace a pattern in a string. This utility function is /** Replace a pattern in a string.
/// useful when converting native units to si or customary.
/// This utility function is useful when converting native units to si or customary.
/// @param orig: string to search for patterns
/// @param rep: the pattern to replace @param orig: string to search for patterns
/// @param with: the replacement pattern @param rep: the pattern to replace
/// @return a new string that has rep replaced with with @param with: the replacement pattern
@return a new string that has rep replaced with with
*/
char *str_replace(char *orig, char *rep, char *with); char *str_replace(char *orig, char *rep, char *with);
/// Make a nice printable string for a frequency. /** Make a nice printable string for a frequency.
///
/// @param freq: the frequency to convert to a string. @param freq: the frequency to convert to a string.
*/
const char *nice_freq (double freq); const char *nice_freq (double freq);
#endif /* INCLUDE_R_UTIL_H_ */ #endif /* INCLUDE_R_UTIL_H_ */

View file

@ -1,3 +1,7 @@
/** @file
Definition of r_cfg application structure.
*/
#ifndef INCLUDE_RTL_433_H_ #ifndef INCLUDE_RTL_433_H_
#define INCLUDE_RTL_433_H_ #define INCLUDE_RTL_433_H_
@ -62,7 +66,7 @@ typedef struct r_cfg {
uint32_t bytes_to_read; uint32_t bytes_to_read;
struct sdr_dev *dev; struct sdr_dev *dev;
int grab_mode; int grab_mode;
int verbosity; // 0=normal, 1=verbose, 2=verbose decoders, 3=debug decoders, 4=trace decoding int verbosity; ///< 0=normal, 1=verbose, 2=verbose decoders, 3=debug decoders, 4=trace decoding.
int verbose_bits; int verbose_bits;
conversion_mode_t conversion_mode; conversion_mode_t conversion_mode;
int report_meta; int report_meta;

View file

@ -1,3 +1,7 @@
/** @file
Definition of r_device and all available decoders.
*/
#ifndef INCLUDE_RTL_433_DEVICES_H_ #ifndef INCLUDE_RTL_433_DEVICES_H_
#define INCLUDE_RTL_433_DEVICES_H_ #define INCLUDE_RTL_433_DEVICES_H_
@ -127,7 +131,7 @@ struct bitbuffer;
struct data; struct data;
typedef struct r_device { typedef struct r_device {
unsigned protocol_num; // fixed sequence number, assigned in main() unsigned protocol_num; ///< fixed sequence number, assigned in main().
/* information provided by each decoder */ /* information provided by each decoder */
char *name; char *name;
@ -141,7 +145,7 @@ typedef struct r_device {
int (*decode_fn)(struct r_device *decoder, struct bitbuffer *bitbuffer); int (*decode_fn)(struct r_device *decoder, struct bitbuffer *bitbuffer);
struct r_device *(*create_fn)(char *args); struct r_device *(*create_fn)(char *args);
unsigned disabled; unsigned disabled;
char **fields; // List of fields this decoder produces; required for CSV output. NULL-terminated. char **fields; ///< List of fields this decoder produces; required for CSV output. NULL-terminated.
/* public for each decoder */ /* public for each decoder */
int verbose; int verbose;
@ -153,8 +157,8 @@ typedef struct r_device {
void *output_ctx; void *output_ctx;
/* private pulse limits (converted to count of samples) */ /* private pulse limits (converted to count of samples) */
float f_short_width; // precision reciprocal for PCM float f_short_width; ///< precision reciprocal for PCM.
float f_long_width; // precision reciprocal for PCM float f_long_width; ///< precision reciprocal for PCM.
int s_short_width; int s_short_width;
int s_long_width; int s_long_width;
int s_reset_limit; int s_reset_limit;

View file

@ -1,13 +1,13 @@
/** /** @file
* IQ sample grabber (ring buffer and dumper) IQ sample grabber (ring buffer and dumper).
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_SAMP_GRAB_H_ #ifndef INCLUDE_SAMP_GRAB_H_
#define INCLUDE_SAMP_GRAB_H_ #define INCLUDE_SAMP_GRAB_H_
@ -34,7 +34,7 @@ void samp_grab_push(samp_grab_t *g, unsigned char *iq_buf, uint32_t len);
void samp_grab_reset(samp_grab_t *g); void samp_grab_reset(samp_grab_t *g);
// grab_end is counted in samples from end of buf /// grab_end is counted in samples from end of buf.
void samp_grab_write(samp_grab_t *g, unsigned grab_len, unsigned grab_end); void samp_grab_write(samp_grab_t *g, unsigned grab_len, unsigned grab_end);
#endif /* INCLUDE_SAMP_GRAB_H_ */ #endif /* INCLUDE_SAMP_GRAB_H_ */

View file

@ -1,13 +1,13 @@
/** /** @file
* SDR input from RTLSDR or SoapySDR SDR input from RTLSDR or SoapySDR.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_SDR_H_ #ifndef INCLUDE_SDR_H_
#define INCLUDE_SDR_H_ #define INCLUDE_SDR_H_
@ -17,114 +17,102 @@
typedef struct sdr_dev sdr_dev_t; typedef struct sdr_dev sdr_dev_t;
typedef void (*sdr_read_cb_t)(unsigned char *buf, uint32_t len, void *ctx); typedef void (*sdr_read_cb_t)(unsigned char *buf, uint32_t len, void *ctx);
/*! /** Find the closest matching device, optionally report status.
* Find the closest matching device, optionally report status
* @param out_dev device output returned
* \param out_dev device output returned @param sample_size stream output sample width returned
* \param sample_size stream output sample width returned @param dev_query a string to be parsed as device spec
* \param dev_query a string to be parsed as device spec @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return dev 0 if successful
* \return dev 0 if successful */
*/
int sdr_open(sdr_dev_t **out_dev, int *sample_size, char *dev_query, int verbose); int sdr_open(sdr_dev_t **out_dev, int *sample_size, char *dev_query, int verbose);
/*! /** Close the device, optionally report status.
* Close the device, optionally report status
* @param dev the device handle
* \param dev the device handle @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_close(sdr_dev_t *dev); int sdr_close(sdr_dev_t *dev);
/*! /** Set device frequency, optionally report status.
* Set device frequency, optionally report status
* @param dev the device handle
* \param dev the device handle @param frequency in Hz
* \param frequency in Hz @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_set_center_freq(sdr_dev_t *dev, uint32_t freq, int verbose); int sdr_set_center_freq(sdr_dev_t *dev, uint32_t freq, int verbose);
/*! /** Get device frequency.
* Get device frequency
* @param dev the device handle
* \param dev the device handle @return frequency in Hz on success, 0 otherwise
* \return frequency in Hz on success, 0 otherwise */
*/
uint32_t sdr_get_center_freq(sdr_dev_t *dev); uint32_t sdr_get_center_freq(sdr_dev_t *dev);
/*! /** Set the frequency correction value for the device, optionally report status.
* Set the frequency correction value for the device, optionally report status
* @param dev the device handle
* \param dev the device handle @param ppm_error correction value in parts per million (ppm)
* \param ppm_error correction value in parts per million (ppm) @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_set_freq_correction(sdr_dev_t *dev, int ppm, int verbose); int sdr_set_freq_correction(sdr_dev_t *dev, int ppm, int verbose);
/*! /** Enable auto gain, optionally report status.
* Enable auto gain, optionally report status
* @param dev the device handle
* \param dev the device handle @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_set_auto_gain(sdr_dev_t *dev, int verbose); int sdr_set_auto_gain(sdr_dev_t *dev, int verbose);
/*! /** Set tuner gain or gain elements, optionally report status.
* Set tuner gain or gain elements, optionally report status
* @param dev the device handle
* \param dev the device handle @param gain_str in tenths of a dB for RTL-SDR, string of gain element pairs (example LNA=40,VGA=20,AMP=0), or string of overall gain, in dB
* \param gain_str in tenths of a dB for RTL-SDR, string of gain element pairs (example LNA=40,VGA=20,AMP=0), or string of overall gain, in dB @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_set_tuner_gain(sdr_dev_t *dev, char *gain_str, int verbose); int sdr_set_tuner_gain(sdr_dev_t *dev, char *gain_str, int verbose);
/*! /** Set device sample rate, optionally report status.
* Set device sample rate, optionally report status
* @param dev the device handle
* \param dev the device handle @param samp_rate in samples/second
* \param samp_rate in samples/second @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_set_sample_rate(sdr_dev_t *dev, uint32_t rate, int verbose); int sdr_set_sample_rate(sdr_dev_t *dev, uint32_t rate, int verbose);
/*! /** Get device sample rate.
* Get device sample rate
* @param dev the device handle
* \param dev the device handle @return sample rate in samples/second on success, 0 otherwise
* \return sample rate in samples/second on success, 0 otherwise */
*/
uint32_t sdr_get_sample_rate(sdr_dev_t *dev); uint32_t sdr_get_sample_rate(sdr_dev_t *dev);
/*! /** Activate stream (only needed for SoapySDR).
* Activate stream (only needed for SoapySDR)
* @param dev the device handle
* \param dev the device handle @return 0 on success
* \return 0 on success */
*/
int sdr_activate(sdr_dev_t *dev); int sdr_activate(sdr_dev_t *dev);
/*! /** Deactivate stream (only needed for SoapySDR).
* Deactivate stream (only needed for SoapySDR)
* @param dev the device handle
* \param dev the device handle @return 0 on success
* \return 0 on success */
*/
int sdr_deactivate(sdr_dev_t *dev); int sdr_deactivate(sdr_dev_t *dev);
/*! /** Reset buffer (only needed for RTL-SDR), optionally report status.
* Reset buffer (only needed for RTL-SDR), optionally report status
* @param dev the device handle
* \param dev the device handle @param verbose the verbosity level for reports to stderr
* \param verbose the verbosity level for reports to stderr @return 0 on success
* \return 0 on success */
*/
int sdr_reset(sdr_dev_t *dev, int verbose); int sdr_reset(sdr_dev_t *dev, int verbose);
int sdr_start(sdr_dev_t *dev, sdr_read_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len); int sdr_start(sdr_dev_t *dev, sdr_read_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len);

View file

@ -1,13 +1,13 @@
/** /** @file
* Terminal control utility functions. Terminal control utility functions.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#ifndef INCLUDE_TERM_CTL_H_ #ifndef INCLUDE_TERM_CTL_H_
#define INCLUDE_TERM_CTL_H_ #define INCLUDE_TERM_CTL_H_
@ -55,7 +55,7 @@ void term_set_bg(void *ctx, term_color_t color);
#define _Printf_format_string_ #define _Printf_format_string_
#endif #endif
/* /**
* Print to terminal with color-codes inline turned into above colors. * Print to terminal with color-codes inline turned into above colors.
* Takes a var-arg format. * Takes a var-arg format.
* *
@ -70,18 +70,19 @@ void term_set_bg(void *ctx, term_color_t color);
* will print "Hello world" to stder' with no colors. * will print "Hello world" to stder' with no colors.
*/ */
int term_printf(void *ctx, _Printf_format_string_ const char *format, ...) int term_printf(void *ctx, _Printf_format_string_ const char *format, ...)
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
__attribute__ ((format(printf,2,3))) __attribute__ ((format(printf,2,3)))
#endif #endif
; ;
/* /**
* Like 'term_printf()', but no var-arg format. * Like 'term_printf()', but no var-arg format.
* Simply takes a 0-terminated buffer. * Simply takes a 0-terminated buffer.
*/ */
int term_puts(void *ctx, const char *buf); int term_puts(void *ctx, const char *buf);
/* /**
* Change the default color map.
* By default, the color-codes maps to these foreground colour: * By default, the color-codes maps to these foreground colour:
* "~0": always restores terminal-colors; TERM_COLOR_RESET. * "~0": always restores terminal-colors; TERM_COLOR_RESET.
* "~1": print using TERM_COLOR_GREEN. * "~1": print using TERM_COLOR_GREEN.
@ -92,13 +93,11 @@ int term_puts(void *ctx, const char *buf);
* "~6": print using TERM_COLOR_YELLOW. * "~6": print using TERM_COLOR_YELLOW.
* "~7": print using TERM_COLOR_BLACK. * "~7": print using TERM_COLOR_BLACK.
* "~8": print using TERM_COLOR_RED. * "~8": print using TERM_COLOR_RED.
*
* This function can change that.
*/ */
int term_set_color_map(int idx, term_color_t color); int term_set_color_map(int idx, term_color_t color);
/* /**
* Returns the current color-value ('enum term_color') for color-index * Returns the current color-value ('enum term_color') for color-index.
* 'idx'. This index goes from ASCII '0' to 'X'. * 'idx'. This index goes from ASCII '0' to 'X'.
* 'X' = '0' + the dimension of the internal 'color_map[]'. * 'X' = '0' + the dimension of the internal 'color_map[]'.
*/ */

View file

@ -1,12 +1,13 @@
/** /** @file
* Various utility functions for use by device drivers Various utility functions for use by device drivers.
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#ifndef INCLUDE_UTIL_H_ #ifndef INCLUDE_UTIL_H_
#define INCLUDE_UTIL_H_ #define INCLUDE_UTIL_H_
@ -33,7 +34,7 @@ uint8_t reverse8(uint8_t x);
/// @param num_bytes number of bytes to reflect /// @param num_bytes number of bytes to reflect
void reflect_bytes(uint8_t message[], unsigned num_bytes); void reflect_bytes(uint8_t message[], unsigned num_bytes);
/// CRC-4 /// CRC-4.
/// ///
/// @param message[]: array of bytes to check /// @param message[]: array of bytes to check
/// @param nBytes: number of bytes in message /// @param nBytes: number of bytes in message
@ -42,7 +43,7 @@ void reflect_bytes(uint8_t message[], unsigned num_bytes);
/// @return CRC value /// @return CRC value
uint8_t crc4(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init); uint8_t crc4(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init);
/// CRC-7 /// CRC-7.
/// ///
/// @param message[]: array of bytes to check /// @param message[]: array of bytes to check
/// @param nBytes: number of bytes in message /// @param nBytes: number of bytes in message
@ -51,10 +52,10 @@ uint8_t crc4(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8
/// @return CRC value /// @return CRC value
uint8_t crc7(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init); uint8_t crc7(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init);
/// Generic Cyclic Redundancy Check CRC-8 /// Generic Cyclic Redundancy Check CRC-8.
/// ///
/// Example polynomial: 0x31 = x8 + x5 + x4 + 1 (x8 is implicit) /// Example polynomial: 0x31 = x8 + x5 + x4 + 1 (x8 is implicit)
/// Example polynomial: 0x80 = x8 + x7 (a normal bit-by-bit parity XOR) /// Example polynomial: 0x80 = x8 + x7 (a normal bit-by-bit parity XOR)
/// ///
/// @param message[]: array of bytes to check /// @param message[]: array of bytes to check
/// @param nBytes: number of bytes in message /// @param nBytes: number of bytes in message
@ -73,7 +74,7 @@ uint8_t crc8(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8
/// @return CRC value /// @return CRC value
uint8_t crc8le(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init); uint8_t crc8le(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init);
/// CRC-16 LSB /// CRC-16 LSB.
/// Input and output are reflected, i.e. least significant bit is shifted in first. /// Input and output are reflected, i.e. least significant bit is shifted in first.
/// Note that poly and init already need to be reflected. /// Note that poly and init already need to be reflected.
/// ///
@ -84,7 +85,7 @@ uint8_t crc8le(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uin
/// @return CRC value /// @return CRC value
uint16_t crc16lsb(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init); uint16_t crc16lsb(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
/// CRC-16 /// CRC-16.
/// ///
/// @param message[]: array of bytes to check /// @param message[]: array of bytes to check
/// @param nBytes: number of bytes in message /// @param nBytes: number of bytes in message

View file

@ -1,13 +1,13 @@
/** /** @file
* array buffer (string builder). array buffer (string builder).
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* AM signal analyzer AM signal analyzer.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -1,16 +1,14 @@
/** /** @file
* Baseband Various functions for baseband sample processing.
*
* Various functions for baseband sample processing Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
* Copyright (C) 2015 Tommy Vestermark
* Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
* 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
* This program is free software; you can redistribute it and/or modify the Free Software Foundation; either version 2 of the License, or
* it under the terms of the GNU General Public License as published by (at your option) any later version.
* the Free Software Foundation; either version 2 of the License, or */
* (at your option) any later version.
*/
#include "baseband.h" #include "baseband.h"
#include <stdio.h> #include <stdio.h>
@ -18,10 +16,9 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
static uint16_t scaled_squares[256]; static uint16_t scaled_squares[256];
/* precalculate lookup table for envelope detection */ /** precalculate lookup table for envelope detection. */
static void calc_squares() static void calc_squares()
{ {
int i; int i;
@ -29,11 +26,11 @@ static void calc_squares()
scaled_squares[i] = (127 - i) * (127 - i); scaled_squares[i] = (127 - i) * (127 - i);
} }
/** This will give a noisy envelope of OOK/ASK signals /** This will give a noisy envelope of OOK/ASK signals.
* Subtract the bias (-128) and get an envelope estimation Subtract the bias (-128) and get an envelope estimation
* The output will be written in the input buffer The output will be written in the input buffer
* @returns pointer to the input buffer @returns pointer to the input buffer
*/ */
void envelope_detect(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len) void envelope_detect(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
{ {
unsigned long i; unsigned long i;
@ -43,9 +40,9 @@ void envelope_detect(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
} }
/** This will give a noisy envelope of OOK/ASK signals. /** This will give a noisy envelope of OOK/ASK signals.
* Subtracts the bias (-128) and calculates the norm (scaled by 16384). Subtracts the bias (-128) and calculates the norm (scaled by 16384).
* Using a LUT is slower for O1 and above. Using a LUT is slower for O1 and above.
*/ */
void envelope_detect_nolut(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len) void envelope_detect_nolut(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
{ {
unsigned long i; unsigned long i;
@ -56,8 +53,9 @@ void envelope_detect_nolut(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
} }
} }
// note that magnitude emphasizes quiet signals / deemphasizes loud signals /** 122/128, 51/128 Magnitude Estimator for CU8 (SIMD has min/max).
// 122/128, 51/128 Magnitude Estimator for CU8 (SIMD has min/max) Note that magnitude emphasizes quiet signals / deemphasizes loud signals.
*/
void magnitude_est_cu8(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len) void magnitude_est_cu8(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
{ {
unsigned long i; unsigned long i;
@ -71,7 +69,7 @@ void magnitude_est_cu8(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
} }
} }
// True Magnitude for CU8 (sqrt can SIMD but float is slow) /// True Magnitude for CU8 (sqrt can SIMD but float is slow).
void magnitude_true_cu8(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len) void magnitude_true_cu8(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
{ {
unsigned long i; unsigned long i;
@ -82,7 +80,7 @@ void magnitude_true_cu8(uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
} }
} }
// 122/128, 51/128 Magnitude Estimator for CS16 (SIMD has min/max) /// 122/128, 51/128 Magnitude Estimator for CS16 (SIMD has min/max).
void magnitude_est_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len) void magnitude_est_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
{ {
unsigned long i; unsigned long i;
@ -96,7 +94,7 @@ void magnitude_est_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
} }
} }
// True Magnitude for CS16 (sqrt can SIMD but float is slow) /// True Magnitude for CS16 (sqrt can SIMD but float is slow).
void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len) void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
{ {
unsigned long i; unsigned long i;
@ -113,15 +111,15 @@ void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
#define S_CONST (1 << F_SCALE) #define S_CONST (1 << F_SCALE)
#define FIX(x) ((int)(x * S_CONST)) #define FIX(x) ((int)(x * S_CONST))
/** Something that might look like a IIR lowpass filter /** Something that might look like a IIR lowpass filter.
*
* [b,a] = butter(1, Wc) # low pass filter with cutoff pi*Wc radians [b,a] = butter(1, Wc) # low pass filter with cutoff pi*Wc radians
* Q1.15*Q15.0 = Q16.15 Q1.15*Q15.0 = Q16.15
* Q16.15>>1 = Q15.14 Q16.15>>1 = Q15.14
* Q15.14 + Q15.14 + Q15.14 could possibly overflow to 17.14 Q15.14 + Q15.14 + Q15.14 could possibly overflow to 17.14
* but the b coeffs are small so it wont happen but the b coeffs are small so it wont happen
* Q15.14>>14 = Q15.0 \o/ Q15.14>>14 = Q15.0 \o/
*/ */
void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state) void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state)
{ {
/// [b,a] = butter(1, 0.01) -> 3x tau (95%) ~100 samples /// [b,a] = butter(1, 0.01) -> 3x tau (95%) ~100 samples
@ -147,14 +145,15 @@ void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t le
} }
/// Integer implementation of atan2() with int16_t normalized output /** Integer implementation of atan2() with int16_t normalized output.
///
/// Returns arc tangent of y/x across all quadrants in radians Returns arc tangent of y/x across all quadrants in radians.
/// Error max 0.07 radians Error max 0.07 radians.
/// Reference: http://dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization Reference: http://dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization
/// @param y: Numerator (imaginary value of complex vector) @param y: Numerator (imaginary value of complex vector)
/// @param x: Denominator (real value of complex vector) @param x: Denominator (real value of complex vector)
/// @return angle in radians (Pi equals INT16_MAX) @return angle in radians (Pi equals INT16_MAX)
*/
int16_t atan2_int16(int16_t y, int16_t x) int16_t atan2_int16(int16_t y, int16_t x)
{ {
static int32_t const I_PI_4 = INT16_MAX/4; // M_PI/4 static int32_t const I_PI_4 = INT16_MAX/4; // M_PI/4
@ -224,7 +223,7 @@ void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_s
#define S_CONST32 (1 << F_SCALE32) #define S_CONST32 (1 << F_SCALE32)
#define FIX32(x) ((int)(x * S_CONST32)) #define FIX32(x) ((int)(x * S_CONST32))
// for evaluation /// for evaluation.
int32_t atan2_int32(int32_t y, int32_t x) int32_t atan2_int32(int32_t y, int32_t x)
{ {
static int64_t const I_PI_4 = INT32_MAX / 4; // M_PI/4 static int64_t const I_PI_4 = INT32_MAX / 4; // M_PI/4
@ -246,7 +245,7 @@ int32_t atan2_int32(int32_t y, int32_t x)
return angle; return angle;
} }
// for evaluation /// for evaluation.
void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state) void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state)
{ {
/// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples /// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples
@ -290,7 +289,6 @@ void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long
state->xlp = xlp_old; state->ylp = ylp_old; state->xlp = xlp_old; state->ylp = ylp_old;
} }
void baseband_init(void) void baseband_init(void)
{ {
calc_squares(); calc_squares();

View file

@ -1,14 +1,13 @@
/** /** @file
* Bit buffer A two-dimensional bit buffer consisting of bytes.
*
* A two-dimensional bit buffer consisting of bytes Copyright (C) 2015 Tommy Vestermark
*
* Copyright (C) 2015 Tommy Vestermark This program is free software; you can redistribute it and/or modify
* 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
* it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
* (at your option) any later version. */
*/
#include "bitbuffer.h" #include "bitbuffer.h"
#include <stdio.h> #include <stdio.h>

View file

@ -1,18 +1,18 @@
/** /** @file
* Light-weight (i.e. dumb) config-file parser Light-weight (i.e. dumb) config-file parser.
*
* - a valid config line is a keyword followed by an argument to the end of line - a valid config line is a keyword followed by an argument to the end of line
* - whitespace around the keyword is ignored - whitespace around the keyword is ignored
* - comments start with a hash sign, no inline comments, empty lines are ok. - comments start with a hash sign, no inline comments, empty lines are ok.
* - whitespace is space and tab - whitespace is space and tab
*
* Copyright (C) 2018 Christian W. Zuckschwerdt <zany@triq.net> Copyright (C) 2018 Christian W. Zuckschwerdt <zany@triq.net>
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* High-level utility functions for decoders High-level utility functions for decoders.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* Various utility functions handling file formats Various utility functions handling file formats.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -211,7 +211,7 @@ char const *last_plain_colon(char const *p)
return found; return found;
} }
/* /**
This will detect file info and overrides. This will detect file info and overrides.
Parse "[0-9]+(\.[0-9]+)?[A-Za-z]" Parse "[0-9]+(\.[0-9]+)?[A-Za-z]"

View file

@ -1,13 +1,13 @@
/** /** @file
* Generic list Generic list.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include "list.h" #include "list.h"
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* Option parsing functions to complement getopt. Option parsing functions to complement getopt.
*
* Copyright (C) 2017 Christian Zuckschwerdt Copyright (C) 2017 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include "optparse.h" #include "optparse.h"
#include <stdio.h> #include <stdio.h>

View file

@ -1,14 +1,15 @@
/** /** @file
* Pulse demodulation functions Pulse demodulation functions.
*
* Binary demodulators (PWM/PPM/Manchester/...) using a pulse data structure as input Binary demodulators (PWM/PPM/Manchester/...) using a pulse data structure as input.
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#include "pulse_demod.h" #include "pulse_demod.h"
#include "bitbuffer.h" #include "bitbuffer.h"

View file

@ -1,12 +1,13 @@
/** /** @file
* Pulse detection functions Pulse detection functions.
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#include "pulse_detect.h" #include "pulse_detect.h"
#include "pulse_demod.h" #include "pulse_demod.h"

View file

@ -1,12 +1,13 @@
/** /** @file
* Various utility functions for use by applications Various utility functions for use by applications
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#include "r_util.h" #include "r_util.h"
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,24 +1,24 @@
/* /** @file
* rtl_433, turns your Realtek RTL2832 based DVB dongle into a 433.92MHz generic data receiver rtl_433, turns your Realtek RTL2832 based DVB dongle into a 433.92MHz generic data receiver.
* Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
* Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
* Based on rtl_sdr
* Based on rtl_sdr
* Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de> Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de>
*
* This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* IQ sample grabber (ring buffer and dumper) IQ sample grabber (ring buffer and dumper).
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -1,17 +1,17 @@
/** /** @file
* SDR input from RTLSDR or SoapySDR SDR input from RTLSDR or SoapySDR.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
* based on code based on code
* Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de> Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de>
* Copyright (C) 2014 by Kyle Keen <keenerd@gmail.com> Copyright (C) 2014 by Kyle Keen <keenerd@gmail.com>
* Copyright (C) 2016 by Robert X. Seger Copyright (C) 2016 by Robert X. Seger
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,13 +1,13 @@
/** /** @file
* Terminal control utility functions. Terminal control utility functions.
*
* Copyright (C) 2018 Christian Zuckschwerdt Copyright (C) 2018 Christian Zuckschwerdt
*
* This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>

View file

@ -1,12 +1,13 @@
/** /** @file
* Various utility functions for use by device drivers Various utility functions for use by device drivers.
*
* Copyright (C) 2015 Tommy Vestermark 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 This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or it under the terms of the GNU General Public License as published by
* (at your option) any later version. the Free Software Foundation; either version 2 of the License, or
*/ (at your option) any later version.
*/
#include "util.h" #include "util.h"
#include <stdlib.h> #include <stdlib.h>