Add per device verbosity parameter

This commit is contained in:
Christian W. Zuckschwerdt 2021-07-02 09:02:17 +02:00
parent 2f42f154ab
commit f5390cc368
14 changed files with 40 additions and 67 deletions

View file

@ -663,10 +663,6 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
bitbuffer_invert(bitbuffer);
if (decoder->verbose > 1) {
bitbuffer_printf(bitbuffer, "%s: ", __func__);
}
for (uint16_t brow = 0; brow < bitbuffer->num_rows; ++brow) {
browlen = (bitbuffer->bits_per_row[brow] + 7)/8;
bb = bitbuffer->bb[brow];
@ -1122,9 +1118,6 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0)
return DECODE_FAIL_SANITY;
if (decoder->verbose > 1)
bitbuffer_printf(bitbuffer, "%s: ", __func__);
// calculate the checksum and only continue if we have a matching checksum
uint8_t chk = lfsr_digest8(b, 3, 0x98, 0xf1);
if (chk != b[3])
@ -1169,9 +1162,6 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
if (row < 0)
return DECODE_ABORT_EARLY;
if (decoder->verbose > 1)
bitbuffer_printf(bitbuffer, "%s: ", __func__);
if (bitbuffer->bits_per_row[row] > 25)
return DECODE_ABORT_LENGTH;
@ -1237,10 +1227,6 @@ static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
bitbuffer_invert(bitbuffer);
if (decoder->verbose > 1) {
bitbuffer_printf(bitbuffer, "%s: ", __func__);
}
// This sensor repeats a signal three times. Combine as fallback.
uint8_t *b_rows[3] = {0};
int n_rows = 0;

View file

@ -43,10 +43,6 @@ static int burnhardbbq_decode(r_device *decoder, bitbuffer_t *bitbuffer)
bitbuffer_invert(bitbuffer);
if (decoder->verbose > 1) {
bitbuffer_printf(bitbuffer, "%s: ", __func__);
}
// All three rows contain the same information. Return on first decoded row.
int ret = 0;
for (int i = 0; i < bitbuffer->num_rows; ++i) {

View file

@ -297,8 +297,8 @@ static int directv_decode(r_device *decoder, bitbuffer_t *bitbuffer)
bit_len = bitbuffer->bits_per_row[r];
if ((bit_len < ROW_BITLEN_MIN) || (bit_len > ROW_BITLEN_MAX)) {
if (decoder->verbose >= 2) {
fprintf(stderr, "directv: incorrect number of bits in bitbuffer: %d (expected between %d and %d).\n", bit_len, ROW_BITLEN_MIN, ROW_BITLEN_MAX);
if (decoder->verbose > 1) {
fprintf(stderr, "%s: incorrect number of bits in bitbuffer: %d (expected between %d and %d).\n", __func__, bit_len, ROW_BITLEN_MIN, ROW_BITLEN_MAX);
}
return DECODE_FAIL_SANITY;
}
@ -307,22 +307,22 @@ static int directv_decode(r_device *decoder, bitbuffer_t *bitbuffer)
// Decode the message symbols
dtv_bit_len = bitrow_dpwm_decode(bitrow, bit_len, 0, dtv_buf, &row_sync_pos, &row_sync_len);
if (decoder->verbose >= 2) {
bitrow_printf(dtv_buf, dtv_bit_len, "directv: SYNC at pos:%u for %u symbols. DPWM Decoded Message: ", row_sync_pos, row_sync_len);
if (decoder->verbose > 1) {
bitrow_printf(dtv_buf, dtv_bit_len, "%s: SYNC at pos:%u for %u symbols. DPWM Decoded Message: ", __func__, row_sync_pos, row_sync_len);
}
// Make sure we have exactly 40 bits (DTV_BITLEN_MAX)
if (dtv_bit_len != DTV_BITLEN_MAX) {
if (decoder->verbose >= 2) {
fprintf(stderr, "directv: Incorrect number of decoded bits: %u (should be %d).\n", dtv_bit_len, DTV_BITLEN_MAX);
if (decoder->verbose > 1) {
fprintf(stderr, "%s: Incorrect number of decoded bits: %u (should be %d).\n", __func__, dtv_bit_len, DTV_BITLEN_MAX);
}
return DECODE_ABORT_LENGTH;
}
// First byte should be 0x10 (model number?)
if (dtv_buf[0] != 0x10) {
if (decoder->verbose >= 2) {
fprintf(stderr, "directv: Incorrect Model ID number: 0x%02X (should be 0x10).\n", dtv_buf[0]);
if (decoder->verbose > 1) {
fprintf(stderr, "%s: Incorrect Model ID number: 0x%02X (should be 0x10).\n", __func__, dtv_buf[0]);
}
return DECODE_FAIL_SANITY;
}
@ -335,8 +335,8 @@ static int directv_decode(r_device *decoder, bitbuffer_t *bitbuffer)
(dtv_buf[4] >> 4) ) & 0x0F;
checksum_2 = dtv_buf[4] & 0x0F;
if (checksum_1 != checksum_2) {
if (decoder->verbose >= 2) {
fprintf(stderr, "directv: Checksum failed: 0x%01X should match 0x%01X\n", checksum_1, checksum_2);
if (decoder->verbose > 1) {
fprintf(stderr, "%s: Checksum failed: 0x%01X should match 0x%01X\n", __func__, checksum_1, checksum_2);
}
return DECODE_FAIL_MIC;
}
@ -345,8 +345,8 @@ static int directv_decode(r_device *decoder, bitbuffer_t *bitbuffer)
unsigned dtv_device_id;
dtv_device_id = dtv_buf[1] << 12 | dtv_buf[2] << 4 | dtv_buf[3] >> 4;
if (dtv_device_id > 999999) {
if (decoder->verbose >= 2) {
fprintf(stderr, "directv: Bad Device ID: %u (should be between 000000 and 999999).\n", dtv_device_id);
if (decoder->verbose > 1) {
fprintf(stderr, "%s: Bad Device ID: %u (should be between 000000 and 999999).\n", __func__, dtv_device_id);
}
return DECODE_FAIL_SANITY;
}

View file

@ -113,10 +113,6 @@ static int dsc_callback(r_device *decoder, bitbuffer_t *bitbuffer)
int s_closed, s_event, s_tamper, s_battery_low;
int s_xactivity, s_xtamper1, s_xtamper2, s_exception;
if (decoder->verbose > 1) {
bitbuffer_printf(bitbuffer, "%s: ", __func__);
}
for (int row = 0; row < bitbuffer->num_rows; row++) {
if (decoder->verbose > 1 && bitbuffer->bits_per_row[row] > 0 ) {
fprintf(stderr, "%s: row %d bit count %d\n", __func__,

View file

@ -71,10 +71,6 @@ static int efergy_optical_callback(r_device *decoder, bitbuffer_t *bitbuffer)
}
}
if (decoder->verbose > 1) {
bitbuffer_printf(bitbuffer, "%s: matched ", __func__);
}
// reject false positives
if ((bytes[8] == 0) && (bytes[9] == 0) && (bytes[10] == 0) && (bytes[11] == 0)) {
return DECODE_FAIL_SANITY;

View file

@ -410,7 +410,7 @@ static int fineoffset_WH0290_callback(r_device *decoder, bitbuffer_t *bitbuffer)
bit_offset = bitbuffer_search(bitbuffer, 0, 0, preamble, sizeof(preamble) * 8) + sizeof(preamble) * 8;
if (bit_offset + sizeof(b) * 8 > bitbuffer->bits_per_row[0]) { // Did not find a big enough package
if (decoder->verbose)
bitbuffer_printf(bitbuffer, "Fineoffset_WH0290: short package. Row length: %u. Header index: %u\n", bitbuffer->bits_per_row[0], bit_offset);
bitbuffer_printf(bitbuffer, "%s: short package. Row length: %u. Header index: %u\n", __func__, bitbuffer->bits_per_row[0], bit_offset);
return DECODE_ABORT_LENGTH;
}
bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, b, sizeof(b) * 8);
@ -423,7 +423,7 @@ static int fineoffset_WH0290_callback(r_device *decoder, bitbuffer_t *bitbuffer)
}
if (crc != b[6] || checksum != b[7]) {
if (decoder->verbose) {
fprintf(stderr, "Fineoffset_WH0280: Checksum error: %02x %02x\n", crc, checksum);
fprintf(stderr, "%s: Checksum error: %02x %02x\n", __func__, crc, checksum);
}
return DECODE_FAIL_MIC;
}
@ -507,7 +507,7 @@ static int fineoffset_WH25_callback(r_device *decoder, bitbuffer_t *bitbuffer)
bit_offset = bitbuffer_search(bitbuffer, 0, 100, preamble, sizeof(preamble) * 8) + sizeof(preamble) * 8;
if (bit_offset + sizeof(b) * 8 > bitbuffer->bits_per_row[0]) { // Did not find a big enough package
if (decoder->verbose)
bitbuffer_printf(bitbuffer, "Fineoffset_WH25: short package. Header index: %u\n", bit_offset);
bitbuffer_printf(bitbuffer, "%s: short package. Header index: %u\n", __func__, bit_offset);
return DECODE_ABORT_LENGTH;
}
bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, b, sizeof(b) * 8);
@ -520,7 +520,7 @@ static int fineoffset_WH25_callback(r_device *decoder, bitbuffer_t *bitbuffer)
}
else if (msg_type != 0xe0) {
if (decoder->verbose)
fprintf(stderr, "Fineoffset_WH25: Msg type unknown: %2x\n", b[0]);
fprintf(stderr, "%s: Msg type unknown: %2x\n", __func__, b[0]);
if (b[0] == 0x41) {
return fineoffset_WH0290_callback(decoder, bitbuffer); // abort and try WH0290
}
@ -531,7 +531,7 @@ static int fineoffset_WH25_callback(r_device *decoder, bitbuffer_t *bitbuffer)
int sum = (add_bytes(b, 6) & 0xff) - b[6];
if (sum) {
if (decoder->verbose)
bitrow_printf(b, sizeof (b) * 8, "Fineoffset_WH25: Checksum error: ");
bitrow_printf(b, sizeof (b) * 8, "%s: Checksum error: ", __func__);
return DECODE_FAIL_MIC;
}
@ -540,7 +540,7 @@ static int fineoffset_WH25_callback(r_device *decoder, bitbuffer_t *bitbuffer)
bitsum = ((bitsum & 0x0f) << 4) | (bitsum >> 4); // Swap nibbles
if (type == 25 && bitsum != b[7]) { // only check for WH25
if (decoder->verbose)
bitrow_printf(b, sizeof (b) * 8, "Fineoffset_WH25: Bitsum error: ");
bitrow_printf(b, sizeof (b) * 8, "%s: Bitsum error: ", __func__);
return DECODE_FAIL_MIC;
}
@ -624,7 +624,7 @@ static int fineoffset_WH51_callback(r_device *decoder, bitbuffer_t *bitbuffer)
bit_offset = bitbuffer_search(bitbuffer, 0, 0, preamble, sizeof(preamble) * 8) + sizeof(preamble) * 8;
if (bit_offset + sizeof(b) * 8 > bitbuffer->bits_per_row[0]) { // Did not find a big enough package
if (decoder->verbose)
bitbuffer_printf(bitbuffer, "Fineoffset_WH51: short package. Header index: %u\n", bit_offset);
bitbuffer_printf(bitbuffer, "%s: short package. Header index: %u\n", __func__, bit_offset);
return DECODE_ABORT_LENGTH;
}
bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, b, sizeof(b) * 8);
@ -632,21 +632,21 @@ static int fineoffset_WH51_callback(r_device *decoder, bitbuffer_t *bitbuffer)
// Verify family code
if (b[0] != 0x51) {
if (decoder->verbose)
fprintf(stderr, "Fineoffset_WH51: Msg family unknown: %2x\n", b[0]);
fprintf(stderr, "%s: Msg family unknown: %2x\n", __func__, b[0]);
return DECODE_ABORT_EARLY;
}
// Verify checksum
if ((add_bytes(b, 13) & 0xff) != b[13]) {
if (decoder->verbose)
bitrow_printf(b, sizeof (b) * 8, "Fineoffset_WH51: Checksum error: ");
bitrow_printf(b, sizeof (b) * 8, "%s: Checksum error: ", __func__);
return DECODE_FAIL_MIC;
}
// Verify crc
if (crc8(b, 12, 0x31, 0) != b[12]) {
if (decoder->verbose)
bitrow_printf(b, sizeof (b) * 8, "Fineoffset_WH51: Bitsum error: ");
bitrow_printf(b, sizeof (b) * 8, "%s: Bitsum error: ", __func__);
return DECODE_FAIL_MIC;
}

View file

@ -140,7 +140,7 @@ static int fineoffset_wh1080_callback(r_device *decoder, bitbuffer_t *bitbuffer,
int bit_offset = bitbuffer_search(bitbuffer, 0, 0, fsk_preamble, sizeof(fsk_preamble) * 8) + sizeof(fsk_preamble) * 8;
if (bit_offset + sizeof(bbuf) * 8 > bitbuffer->bits_per_row[0]) { // Did not find a big enough package
if (decoder->verbose)
bitbuffer_printf(bitbuffer, "fineoffset_wh1080: short package. Header index: %u\n", bit_offset);
bitbuffer_printf(bitbuffer, "%s: short package. Header index: %u\n", __func__, bit_offset);
return DECODE_ABORT_LENGTH;
}
bitbuffer_extract_bytes(bitbuffer, 0, bit_offset-8, bbuf, sizeof(bbuf) * 8);

View file

@ -75,10 +75,6 @@ static int gt_tmbbq05_decode(r_device *decoder, bitbuffer_t *bitbuffer)
uint8_t b[4],p[4];
data_t *data;
if (decoder->verbose > 1) {
bitbuffer_printf(bitbuffer, "%s: Possible Quigg BBQ: ", __func__);
}
// 33 bit, repeated multiple times (technically it is repeated 8 times, look for 5 identical versions)
int r = bitbuffer_find_repeated_row(bitbuffer, 5, 33);

View file

@ -21,10 +21,10 @@ Microchip HCS200 KeeLoq Code Hopping Encoder based remotes.
Datasheet: DS40138C http://ww1.microchip.com/downloads/en/DeviceDoc/40138c.pdf
The preamble of 12 short pulses is followed by a long 4400 us gap.
The warmup of 12 short pulses is followed by a long 4400 us gap.
There are two packets with a 17500 us gap.
rtl_433 -R 0 -X 'n=name,m=OOK_PWM,s=370,l=772,r=14000,g=4000,t=152,y=0,preamble={12}0xfff'
rtl_433 -R 0 -X 'n=hcs200,m=OOK_PWM,s=370,l=772,r=9000,g=1500,t=152'
*/
#include "decoder.h"
@ -33,7 +33,6 @@ static int hcs200_callback(r_device *decoder, bitbuffer_t *bitbuffer)
{
data_t *data;
uint8_t *b = bitbuffer->bb[0];
int i;
uint32_t encrypted, serial, encrypted_rev, serial_rev;
char encrypted_str[9];
char encrypted_rev_str[9];
@ -47,7 +46,7 @@ static int hcs200_callback(r_device *decoder, bitbuffer_t *bitbuffer)
// Reject codes with an incorrect preamble (expected 0xfff)
if (b[0] != 0xff || (b[1] & 0xf0) != 0xf0) {
if (decoder->verbose > 1)
fprintf(stderr, "HCS200: Preamble not found\n");
fprintf(stderr, "%s: Preamble not found\n", __func__);
return DECODE_ABORT_EARLY;
}

View file

@ -64,7 +64,7 @@ static int oregon_scientific_sl109h_callback(r_device *decoder, bitbuffer_t *bit
sum = add_nibbles(b, 5) & 0xf;
if (sum != chk) {
if (decoder->verbose > 1)
bitbuffer_printf(bitbuffer, "Checksum error in Oregon Scientific SL109H message. Expected: %01x Calculated: %01x\n", chk, sum);
bitbuffer_printf(bitbuffer, "%s: Checksum error. Expected: %01x Calculated: %01x\n", __func__, chk, sum);
continue; // DECODE_FAIL_MIC
}

View file

@ -36,10 +36,6 @@ Bytes 2 to 9 are inverted Manchester with swapped MSB/LSB:
static int steelmate_callback(r_device *decoder, bitbuffer_t *bitbuffer)
{
//if (decoder->verbose) {
// bitbuffer_printf(bitbuffer, "Steelmate TPMS decoder: ");
//}
bitrow_t *bb = bitbuffer->bb;
//Loop through each row of data

View file

@ -71,14 +71,14 @@ static int wt450_callback(r_device *decoder, bitbuffer_t *bitbuffer)
if (bitbuffer->bits_per_row[0] != 36) {
if (decoder->verbose)
fprintf(stderr, "wt450_callback: wrong size of bit per row %d\n",
fprintf(stderr, "%s: wrong size of bit per row %d\n", __func__,
bitbuffer->bits_per_row[0]);
return DECODE_ABORT_LENGTH;
}
if (b[0]>>4 != 0xC) {
if (decoder->verbose)
bitbuffer_printf(bitbuffer, "wt450_callback: wrong preamble\n");
bitbuffer_printf(bitbuffer, "%s: wrong preamble\n", __func__);
return DECODE_ABORT_EARLY;
}
@ -89,7 +89,7 @@ static int wt450_callback(r_device *decoder, bitbuffer_t *bitbuffer)
if (parity) {
if (decoder->verbose)
bitbuffer_printf(bitbuffer, "wt450_callback: wrong parity (%x)\n", parity);
bitbuffer_printf(bitbuffer, "%s: wrong parity (%x)\n", __func__, parity);
return DECODE_FAIL_MIC;
}

View file

@ -44,7 +44,7 @@ static int account_event(r_device *device, bitbuffer_t *bits, char const *demod_
}
// Debug printout
if (!device->decode_fn || (device->verbose && ret > 0)) {
if (!device->decode_fn || (device->verbose && ret > 0) || device->verbose > 1) {
fprintf(stderr, "%s(): %s\n", demod_name, device->name);
bitbuffer_print(bits);
}

View file

@ -210,6 +210,14 @@ void r_free_cfg(r_cfg_t *cfg)
void register_protocol(r_cfg_t *cfg, r_device *r_dev, char *arg)
{
// use arg of 'v', 'vv', 'vvv' as device verbosity
int dev_verbose = 0;
if (arg && arg[0] == 'v' && (!arg[1] || (arg[1] == 'v' && (!arg[2] || arg[2] == 'v')))) {
dev_verbose = strlen(arg);
arg = NULL;
}
// use any other arg as device parameter
r_device *p;
if (r_dev->create_fn) {
p = r_dev->create_fn(arg);
@ -224,7 +232,7 @@ void register_protocol(r_cfg_t *cfg, r_device *r_dev, char *arg)
*p = *r_dev; // copy
}
p->verbose = cfg->verbosity > 0 ? cfg->verbosity - 1 : 0;
p->verbose = dev_verbose ? dev_verbose : (cfg->verbosity > 0 ? cfg->verbosity - 1 : 0);
p->verbose_bits = cfg->verbose_bits;
p->output_fn = data_acquired_handler;