aboutsummaryrefslogtreecommitdiff
path: root/tools/ootx_decode/ootx_decoder.c
diff options
context:
space:
mode:
authorJosh Allen <axlecrusher@gmail.com>2017-02-10 06:54:58 -0500
committerJosh Allen <axlecrusher@gmail.com>2017-02-10 06:54:58 -0500
commit9ac3cddf749366f81540aac549ac7583602b7170 (patch)
tree606fa3d8c650bbbb23133cbe91a238bbc28b62ae /tools/ootx_decode/ootx_decoder.c
parent917a7f7754e47567bf9102b6c26b6649ae6b28dd (diff)
downloadlibsurvive-9ac3cddf749366f81540aac549ac7583602b7170.tar.gz
libsurvive-9ac3cddf749366f81540aac549ac7583602b7170.tar.bz2
crc check decoded data
Diffstat (limited to 'tools/ootx_decode/ootx_decoder.c')
-rw-r--r--tools/ootx_decode/ootx_decoder.c10
1 files changed, 9 insertions, 1 deletions
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 <assert.h>
#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();
}