From af74daf092678d93a3e3622637f6995d4c69f5e0 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 8 Dec 2015 11:14:00 -0800 Subject: [PATCH] AIS Packet refactor, consolidating duplicate packet length code. --- firmware/application/app_ais.cpp | 54 ++++++++++++++------------------ firmware/application/app_ais.hpp | 7 +++++ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/firmware/application/app_ais.cpp b/firmware/application/app_ais.cpp index a7711818..b222e611 100644 --- a/firmware/application/app_ais.cpp +++ b/firmware/application/app_ais.cpp @@ -130,23 +130,6 @@ struct PacketTooLong { } }; -struct CRCCheck { - bool operator()(const ::Packet& packet) { - const size_t fcs_length = 16; - const size_t data_and_fcs_length = packet.size() - 7; - const size_t data_length = data_and_fcs_length - fcs_length; - - CRCFieldReader field_crc { packet }; - CRC ais_fcs { 0x1021, 0xffff, 0xffff }; - - for(size_t i=0; i(field_.read(start_bit, 28) << 4) / 16; } +bool Packet::crc_ok() const { + CRCFieldReader field_crc { packet_ }; + CRC ais_fcs { 0x1021, 0xffff, 0xffff }; + + for(size_t i=0; i