From b9ea7fa7866263596f5fcf93c6c2c1a778554d62 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 7 Dec 2015 11:38:35 -0800 Subject: [PATCH] ERT CRC checking for SCM packets. IDM coming as soon as I can address packet truncation... --- firmware/application/app_ert.cpp | 17 +++++++++++++++++ firmware/application/app_ert.hpp | 2 ++ 2 files changed, 19 insertions(+) diff --git a/firmware/application/app_ert.cpp b/firmware/application/app_ert.cpp index a6cbde5e4..6a08888a3 100644 --- a/firmware/application/app_ert.cpp +++ b/firmware/application/app_ert.cpp @@ -29,6 +29,7 @@ using namespace portapack; #include "lpc43xx_cpp.hpp" using namespace lpc43xx; +#include "crc.hpp" #include "string_format.hpp" namespace ert { @@ -71,6 +72,21 @@ Consumption Packet::consumption() const { return invalid_consumption; } +bool Packet::crc_ok() const { + if( type() == ERTPacket::Type::SCM ) { + CRC ert_bch { 0x6f63 }; + size_t start_bit = 5; + auto crc_calculated = ert_bch.calculate_byte(0x0000, reader_.read(0, start_bit)); + for(size_t i=start_bit; i;