From 9ac3cddf749366f81540aac549ac7583602b7170 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Fri, 10 Feb 2017 06:54:58 -0500 Subject: crc check decoded data --- tools/ootx_decode/ootx_decoder.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decoder.c') diff --git a/tools/ootx_decode/ootx_decoder.c b/tools/ootx_decode/ootx_decoder.c index 70a88b5..2bd818f 100644 --- a/tools/ootx_decode/ootx_decoder.c +++ b/tools/ootx_decode/ootx_decoder.c @@ -9,6 +9,7 @@ #include #include "ootx_decoder.h" +#include "crc32.h" //char* fmt_str = "L Y HMD %d 5 1 206230 %d\n"; @@ -103,7 +104,14 @@ void ootx_process_bit(uint32_t length) { op.length = *(uint16_t*)buffer; op.data = buffer+2; op.crc32 = *(uint32_t*)(buffer+2+op.length); - if (ootx_packet_clbk) ootx_packet_clbk(&op); + + uint32_t crc = crc32(0xffffffff,op.data,op.length); + + if (crc != op.crc32) { + printf("CRC mismatch\n"); + } + + if ((crc == op.crc32) && ootx_packet_clbk) ootx_packet_clbk(&op); ootx_reset_buffer(); } -- cgit v1.2.3