rtl433  UNKNOWN
RTL-433 utility
bitbuffer.h File Reference

A two-dimensional bit buffer consisting of bytes. More...

Go to the source code of this file.

Data Structures

struct  bitbuffer
 Bit buffer. More...
 

Typedefs

typedef uint8_t bitrow_t[BITBUF_COLS]
 
typedef bitrow_t bitarray_t[BITBUF_ROWS]
 
typedef struct bitbuffer bitbuffer_t
 Bit buffer. More...
 

Functions

void bitbuffer_clear (bitbuffer_t *bits)
 Clear the content of the bitbuffer. More...
 
void bitbuffer_add_bit (bitbuffer_t *bits, int bit)
 Add a single bit at the end of the bitbuffer (MSB first). More...
 
void bitbuffer_add_row (bitbuffer_t *bits)
 Add a new row to the bitbuffer. More...
 
void bitbuffer_add_sync (bitbuffer_t *bits)
 Increment sync counter, add new row if not empty. More...
 
void bitbuffer_extract_bytes (bitbuffer_t *bitbuffer, unsigned row, unsigned pos, uint8_t *out, unsigned len)
 Extract (potentially unaligned) bytes from the bit buffer. Len is bits. More...
 
void bitbuffer_invert (bitbuffer_t *bits)
 Invert all bits in the bitbuffer (do not invert the empty bits). More...
 
void bitbuffer_nrzs_decode (bitbuffer_t *bits)
 Non-Return-to-Zero Space (NRZI) decode the bitbuffer. More...
 
void bitbuffer_nrzm_decode (bitbuffer_t *bits)
 Non-Return-to-Zero Mark (NRZI) decode the bitbuffer. More...
 
void bitbuffer_print (const bitbuffer_t *bits)
 Print the content of the bitbuffer. More...
 
void bitbuffer_debug (const bitbuffer_t *bits)
 Debug the content of the bitbuffer. More...
 
void bitrow_print (bitrow_t const bitrow, unsigned bit_len)
 Print the content of a bit row (byte buffer). More...
 
void bitrow_debug (bitrow_t const bitrow, unsigned bit_len)
 Debug the content of a bit row (byte buffer). More...
 
void bitbuffer_parse (bitbuffer_t *bits, const char *code)
 Parse a string into a bitbuffer. More...
 
unsigned bitbuffer_search (bitbuffer_t *bitbuffer, unsigned row, unsigned start, const uint8_t *pattern, unsigned pattern_bits_len)
 Search the specified row of the bitbuffer, starting from bit 'start', for the pattern provided. More...
 
unsigned bitbuffer_manchester_decode (bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf, unsigned max)
 Manchester decoding from one bitbuffer into another, starting at the specified row and start bit. More...
 
unsigned bitbuffer_differential_manchester_decode (bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf, unsigned max)
 Differential Manchester decoding from one bitbuffer into another, starting at the specified row and start bit. More...
 
int compare_rows (bitbuffer_t *bits, unsigned row_a, unsigned row_b)
 Function to compare bitbuffer rows and count repetitions. More...
 
unsigned count_repeats (bitbuffer_t *bits, unsigned row)
 
int bitbuffer_find_repeated_row (bitbuffer_t *bits, unsigned min_repeats, unsigned min_bits)
 Find a repeated row that has a minimum count of bits. More...
 
static uint8_t bitrow_get_bit (const bitrow_t bitrow, unsigned bit_idx)
 Return a single bit from a bitrow at bit_idx position. More...
 
static uint8_t bitrow_get_byte (const bitrow_t bitrow, unsigned bit_idx)
 Return a single byte from a bitrow at bit_idx position (which may be unaligned). More...
 

Detailed Description

A two-dimensional bit buffer consisting of bytes.

Copyright (C) 2015 Tommy Vestermark

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

Typedef Documentation

◆ bitarray_t

typedef bitrow_t bitarray_t[BITBUF_ROWS]

◆ bitbuffer_t

typedef struct bitbuffer bitbuffer_t

Bit buffer.

◆ bitrow_t

typedef uint8_t bitrow_t[BITBUF_COLS]

Function Documentation

◆ bitbuffer_add_bit()

◆ bitbuffer_add_row()

◆ bitbuffer_add_sync()

void bitbuffer_add_sync ( bitbuffer_t bits)

Increment sync counter, add new row if not empty.

References bitbuffer_add_row(), bitbuffer::bits_per_row, bitbuffer::num_rows, and bitbuffer::syncs_before_row.

Referenced by pulse_demod_ppm(), and pulse_demod_pwm().

◆ bitbuffer_clear()

◆ bitbuffer_debug()

void bitbuffer_debug ( const bitbuffer_t bits)

Debug the content of the bitbuffer.

References print_bitbuffer().

Referenced by bitbuffer_debugf().

◆ bitbuffer_differential_manchester_decode()

unsigned bitbuffer_differential_manchester_decode ( bitbuffer_t inbuf,
unsigned  row,
unsigned  start,
bitbuffer_t outbuf,
unsigned  max 
)

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) bits from the input buffer). Return the bit position in the input row (i.e. returns start + 2*outbuf->bits_per_row[0]).

References bitbuffer::bb, bit(), bitbuffer_add_bit(), and bitbuffer::bits_per_row.

Referenced by tpms_pmv107j_decode(), and tpms_toyota_decode().

◆ bitbuffer_extract_bytes()

◆ bitbuffer_find_repeated_row()

◆ bitbuffer_invert()

◆ bitbuffer_manchester_decode()

unsigned bitbuffer_manchester_decode ( bitbuffer_t inbuf,
unsigned  row,
unsigned  start,
bitbuffer_t outbuf,
unsigned  max 
)

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) bits from the input buffer). Return the bit position in the input row (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.

References bitbuffer::bb, bit(), bitbuffer_add_bit(), and bitbuffer::bits_per_row.

Referenced by current_cost_callback(), maverick_et73x_callback(), newkaku_callback(), nexa_callback(), oil_standard_decode(), oil_watchman_callback(), oregon_scientific_v2_1_decode(), proove_callback(), tfa_303196_callback(), tpms_citroen_decode(), tpms_ford_decode(), tpms_jansite_decode(), and tpms_renault_decode().

◆ bitbuffer_nrzm_decode()

void bitbuffer_nrzm_decode ( bitbuffer_t bits)

Non-Return-to-Zero Mark (NRZI) decode the bitbuffer.

"One" is represented by change in level, "Zero" is represented by no change in level.

References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.

◆ bitbuffer_nrzs_decode()

void bitbuffer_nrzs_decode ( bitbuffer_t bits)

Non-Return-to-Zero Space (NRZI) decode the bitbuffer.

"One" is represented by no change in level, "Zero" is represented by change in level.

References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.

Referenced by main().

◆ bitbuffer_parse()

void bitbuffer_parse ( bitbuffer_t bits,
const char *  code 
)

◆ bitbuffer_print()

◆ bitbuffer_search()

unsigned bitbuffer_search ( bitbuffer_t bitbuffer,
unsigned  row,
unsigned  start,
const uint8_t pattern,
unsigned  pattern_bits_len 
)

◆ bitrow_debug()

void bitrow_debug ( bitrow_t const  bitrow,
unsigned  bit_len 
)

Debug the content of a bit row (byte buffer).

References print_bitrow().

Referenced by bitrow_debugf().

◆ bitrow_get_bit()

static uint8_t bitrow_get_bit ( const bitrow_t  bitrow,
unsigned  bit_idx 
)
inlinestatic

Return a single bit from a bitrow at bit_idx position.

Referenced by bitrow_dpwm_decode(), lightwave_rf_callback(), and vaillant_vrt340_callback().

◆ bitrow_get_byte()

static uint8_t bitrow_get_byte ( const bitrow_t  bitrow,
unsigned  bit_idx 
)
inlinestatic

Return a single byte from a bitrow at bit_idx position (which may be unaligned).

Referenced by danfoss_cfr_callback(), ft004b_callback(), m_bus_decode_3of6_buffer(), m_bus_mode_c_t_callback(), and m_bus_mode_f_callback().

◆ bitrow_print()

void bitrow_print ( bitrow_t const  bitrow,
unsigned  bit_len 
)

◆ compare_rows()

int compare_rows ( bitbuffer_t bits,
unsigned  row_a,
unsigned  row_b 
)

Function to compare bitbuffer rows and count repetitions.

References bitbuffer::bb, and bitbuffer::bits_per_row.

Referenced by count_repeats().

◆ count_repeats()

unsigned count_repeats ( bitbuffer_t bits,
unsigned  row 
)