rtl433
UNKNOWN
RTL-433 utility
|
Various utility functions for use by device drivers. More...
Go to the source code of this file.
Functions | |
uint8_t | reverse8 (uint8_t x) |
Reverse (reflect) the bits in an 8 bit byte. More... | |
void | reflect_bytes (uint8_t message[], unsigned num_bytes) |
Reflect (reverse LSB to MSB) each byte of a number of bytes. More... | |
uint8_t | reflect4 (uint8_t x) |
Reflect (reverse LSB to MSB) each nibble in an 8 bit byte, preserves nibble order. More... | |
void | reflect_nibbles (uint8_t message[], unsigned num_bytes) |
Reflect (reverse LSB to MSB) each nibble in a number of bytes. More... | |
unsigned | extract_nibbles_4b1s (uint8_t *message, unsigned offset_bits, unsigned num_bits, uint8_t *dst) |
Unstuff nibbles with 1-bit separator (4B1S) to bytes, returns number of successfully unstuffed nibbles. More... | |
uint8_t | crc4 (uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init) |
CRC-4. More... | |
uint8_t | crc7 (uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init) |
CRC-7. More... | |
uint8_t | crc8 (uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init) |
Generic Cyclic Redundancy Check CRC-8. More... | |
uint8_t | crc8le (uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t init) |
"Little-endian" Cyclic Redundancy Check CRC-8 LE Input and output are reflected, i.e. More... | |
uint16_t | crc16lsb (uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init) |
CRC-16 LSB. More... | |
uint16_t | crc16 (uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init) |
CRC-16. More... | |
uint8_t | lfsr_digest8 (uint8_t const message[], unsigned bytes, uint8_t gen, uint8_t key) |
Digest-8 by "LFSR-based Toeplitz hash". More... | |
uint16_t | lfsr_digest16 (uint32_t data, int bits, uint16_t gen, uint16_t key) |
Digest-16 by "LFSR-based Toeplitz hash". More... | |
int | parity8 (uint8_t byte) |
Compute bit parity of a single byte (8 bits). More... | |
int | parity_bytes (uint8_t const message[], unsigned num_bytes) |
Compute bit parity of a number of bytes. More... | |
uint8_t | xor_bytes (uint8_t const message[], unsigned num_bytes) |
Compute XOR (byte-wide parity) of a number of bytes. More... | |
int | add_bytes (uint8_t const message[], unsigned num_bytes) |
Compute Addition of a number of bytes. More... | |
int | add_nibbles (uint8_t const message[], unsigned num_bytes) |
Compute Addition of a number of nibbles (byte wise). More... | |
Various utility functions for use by device drivers.
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.
int add_bytes | ( | uint8_t const | message[], |
unsigned | num_bytes | ||
) |
Compute Addition of a number of bytes.
message | bytes of message data |
num_bytes | number of bytes to sum |
Referenced by acurite_txr_decode(), alecto_ws1200v2_callback(), alecto_ws1200v2_dcf_callback(), esic_emt7110_decode(), fineoffset_WH0530_callback(), fineoffset_WH25_callback(), lacrosse_ws7000_decode(), opus_xt300_callback(), and schrader_EG53MA4_callback().
int add_nibbles | ( | uint8_t const | message[], |
unsigned | num_bytes | ||
) |
Compute Addition of a number of nibbles (byte wise).
message | bytes (of two nibbles) of message data |
num_bytes | number of bytes to sum |
Referenced by oregon_scientific_sl109h_callback().
CRC-16.
message[] | array of bytes to check |
nBytes | number of bytes in message |
polynomial | CRC polynomial |
init | starting crc value |
References bit().
Referenced by danfoss_cfr_callback(), data_output_mqtt_create(), efergy_optical_callback(), honeywell_callback(), ibis_beacon_callback(), ikea_sparsnas_callback(), and m_bus_crc_valid().
CRC-16 LSB.
Input and output are reflected, i.e. least significant bit is shifted in first. Note that poly and init already need to be reflected.
message[] | array of bytes to check |
nBytes | number of bytes in message |
polynomial | CRC polynomial |
init | starting crc value |
References bit().
Referenced by acurite_00275rm_decode(), emontx_callback(), and radiohead_ask_extract().
CRC-4.
message[] | array of bytes to check |
nBytes | number of bytes in message |
polynomial | CRC polynomial |
init | starting crc value |
References bit().
Referenced by esperanza_ews_callback(), kedsum_callback(), philips_aj3650_decode(), and s3318p_callback().
CRC-7.
message[] | array of bytes to check |
nBytes | number of bytes in message |
polynomial | CRC polynomial |
init | starting crc value |
References bit().
Generic Cyclic Redundancy Check CRC-8.
Example polynomial: 0x31 = x8 + x5 + x4 + 1 (x8 is implicit) Example polynomial: 0x80 = x8 + x7 (a normal bit-by-bit parity XOR)
message[] | array of bytes to check |
nBytes | number of bytes in message |
polynomial | byte is from x^7 to x^0 (x^8 is implicitly one) |
init | starting crc value |
References bit().
Referenced by alecto_ws1200v1_callback(), alecto_ws1200v2_callback(), alecto_ws1200v2_dcf_callback(), ambientweather_wh31e_callback(), calibeur_rf104_callback(), ecowitt_decode(), fineoffset_WH0290_callback(), fineoffset_WH0530_callback(), fineoffset_wh1050_callback(), fineoffset_wh1080_callback(), fineoffset_WH24_callback(), fineoffset_WH2_callback(), hideki_ts04_callback(), lacrosse_it(), main(), new_template_decode(), rubicson_crc_check(), schraeder_callback(), tpms_pmv107j_decode(), tpms_renault_decode(), tpms_toyota_decode(), and wg_pb12v1_decode().
"Little-endian" Cyclic Redundancy Check CRC-8 LE Input and output are reflected, i.e.
least significant bit is shifted in first.
message[] | array of bytes to check |
nBytes | number of bytes in message |
polynomial | CRC polynomial |
init | starting crc value |
References bit(), and reverse8().
Referenced by acurite_986_decode(), dsc_callback(), and oil_watchman_callback().
unsigned extract_nibbles_4b1s | ( | uint8_t * | message, |
unsigned | offset_bits, | ||
unsigned | num_bits, | ||
uint8_t * | dst | ||
) |
Unstuff nibbles with 1-bit separator (4B1S) to bytes, returns number of successfully unstuffed nibbles.
message | bytes of message data |
offset_bits | start offset of message in bits |
num_bits | message length in bits |
dst | target buffer for extracted nibbles, at least num_bits/5 size |
Referenced by lacrosse_ws7000_decode().
Digest-16 by "LFSR-based Toeplitz hash".
data | up to 32 bits data, LSB aligned |
bits | number of bits to digest |
gen | key stream generator, needs to includes the MSB if the LFSR is rolling |
key | initial key |
References bit().
Referenced by maverick_et73x_callback(), and tfa_303196_callback().
Digest-8 by "LFSR-based Toeplitz hash".
message | bytes of message data |
bytes | number of bytes to digest |
gen | key stream generator, needs to includes the MSB if the LFSR is rolling |
key | initial key |
Referenced by acurite_606_decode(), and ambient_weather_decode().
int parity8 | ( | uint8_t | byte | ) |
Compute bit parity of a single byte (8 bits).
byte | single byte to check |
Referenced by acurite_6045_decode(), acurite_txr_decode(), hideki_ts04_callback(), and parity_bytes().
int parity_bytes | ( | uint8_t const | message[], |
unsigned | num_bytes | ||
) |
Compute bit parity of a number of bytes.
message | bytes of message data |
num_bytes | number of bytes to sum |
References parity8().
Referenced by companion_wtr001_decode(), and honeywell_wdb_callback().
Reflect (reverse LSB to MSB) each nibble in an 8 bit byte, preserves nibble order.
x | input byte |
Referenced by reflect_nibbles().
void reflect_bytes | ( | uint8_t | message[], |
unsigned | num_bytes | ||
) |
Reflect (reverse LSB to MSB) each byte of a number of bytes.
message | bytes of message data |
num_bytes | number of bytes to reflect |
References reverse8().
Referenced by hideki_ts04_callback(), and ts_ft002_decoder().
void reflect_nibbles | ( | uint8_t | message[], |
unsigned | num_bytes | ||
) |
Reflect (reverse LSB to MSB) each nibble in a number of bytes.
message | bytes of nibble message data |
num_bytes | number of bytes to reflect |
References reflect4().
Referenced by lacrosse_ws7000_decode(), oregon_scientific_v2_1_decode(), and oregon_scientific_v3_decode().
Reverse (reflect) the bits in an 8 bit byte.
x | input byte |
Referenced by acurite_986_decode(), alecto_checksum(), alectov1_callback(), companion_wtr001_decode(), crc8le(), decode_xc0324_message(), flex_callback(), ft004b_callback(), interlogix_callback(), kw9015b_callback(), oregon_scientific_v1_callback(), radiohead_ask_extract(), reflect_bytes(), smoke_gs558_callback(), ss_get_id(), ss_pinentry_parser(), ss_sensor_parser(), steelmate_callback(), tfa_twin_plus_303049_callback(), and vaillant_vrt340_callback().
Compute XOR (byte-wide parity) of a number of bytes.
message | bytes of message data |
num_bytes | number of bytes to sum |
Referenced by decode_xc0324_message(), fineoffset_WH25_callback(), hideki_ts04_callback(), lacrosse_ws7000_decode(), philips_aj7010_decode(), springfield_callback(), ts_ft002_decoder(), and wt450_callback().