From 6ad28759408695a4825738bcc32bc294d1869ca8 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 11:09:38 -0500 Subject: handler for bad crc32 --- tools/ootx_decode/ootx_decode.c | 12 ++++++------ tools/ootx_decode/ootx_decoder.c | 4 ++-- tools/ootx_decode/ootx_decoder.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 0abde2d..9e76d8f 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -44,16 +44,15 @@ void write_to_file(uint8_t *d, uint16_t length){ fclose(fp); } -void bad_crc(ootx_packet* packet) { +void bad_crc(ootx_packet* packet, uint32_t crc) { printf("CRC mismatch\n"); -/* + printf("r:"); - print_crc32(op.crc32); + print_crc32(packet->crc32); printf("c:"); print_crc32(crc); -// write_to_file(op.data,op.length); -*/ + write_to_file(packet->data,packet->length); } ootx_decoder_context ctx[2]; @@ -61,7 +60,6 @@ ootx_decoder_context ctx[2]; void hello_world_test() { // ootx_init_buffer(); ootx_packet_clbk = my_test; - ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; @@ -87,6 +85,7 @@ void hello_world_test() { void raw_test() { ootx_packet_clbk = my_test2; + ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; @@ -146,6 +145,7 @@ void raw_test() { void acode_test() { ootx_packet_clbk = my_test2; + ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; diff --git a/tools/ootx_decode/ootx_decoder.c b/tools/ootx_decode/ootx_decoder.c index 36f93fe..dc5d50a 100644 --- a/tools/ootx_decode/ootx_decoder.c +++ b/tools/ootx_decode/ootx_decoder.c @@ -16,7 +16,7 @@ #define MAX_BUFF_SIZE 1024 void (*ootx_packet_clbk)(ootx_packet* packet) = NULL; -void (*ootx_bad_crc_clbk)(ootx_packet* packet) = NULL; +void (*ootx_bad_crc_clbk)(ootx_packet* packet, uint32_t crc) = NULL; void ootx_pump_bit(ootx_decoder_context *ctx, uint8_t dbit); @@ -194,7 +194,7 @@ void ootx_pump_bit(ootx_decoder_context *ctx, uint8_t dbit) { crc = crc32( crc, op.data,op.length); if (crc != op.crc32) { - if (ootx_bad_crc_clbk != NULL) ootx_bad_crc_clbk(&op); + if (ootx_bad_crc_clbk != NULL) ootx_bad_crc_clbk(&op,crc); } else if (ootx_packet_clbk != NULL) { ootx_packet_clbk(&op); diff --git a/tools/ootx_decode/ootx_decoder.h b/tools/ootx_decode/ootx_decoder.h index 8f6129b..38c273b 100644 --- a/tools/ootx_decode/ootx_decoder.h +++ b/tools/ootx_decode/ootx_decoder.h @@ -66,6 +66,6 @@ uint8_t ootx_pump_greatest_bit(ootx_decoder_context *ctx); uint8_t ootx_decode_bit(uint32_t length); extern void (*ootx_packet_clbk)(ootx_packet* packet); -extern void (*ootx_bad_crc_clbk)(ootx_packet* packet); +extern void (*ootx_bad_crc_clbk)(ootx_packet* packet, uint32_t crc); #endif \ No newline at end of file -- cgit v1.2.3