From b61ed7dce258d310a5f8c8deec3a5e09e4026c3e Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 7 Dec 2015 15:32:26 -0800 Subject: [PATCH] Clean up ERT CRC code, add IDM CRC checking. --- firmware/application/app_ert.cpp | 35 +++++++++++++++++++++++--------- firmware/application/app_ert.hpp | 3 +++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/firmware/application/app_ert.cpp b/firmware/application/app_ert.cpp index 0000716f7..96417703b 100644 --- a/firmware/application/app_ert.cpp +++ b/firmware/application/app_ert.cpp @@ -77,18 +77,32 @@ ManchesterFormatted Packet::symbols_formatted() const { } 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 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 ert_crc_ccitt { 0x1021 }; + uint16_t crc_calculated = 0xffff; + for(size_t i=0; i