From fe1d296b48ff8481e0f0849c6364e86627992a98 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Sun, 23 Apr 2023 01:29:51 -0500 Subject: [PATCH] Support for ERT SCM+ meter protocol --- firmware/common/ert_packet.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/firmware/common/ert_packet.cpp b/firmware/common/ert_packet.cpp index ff9e7d100..5286d751d 100644 --- a/firmware/common/ert_packet.cpp +++ b/firmware/common/ert_packet.cpp @@ -47,6 +47,9 @@ ID Packet::id() const { const auto lsb = reader_.read(35, 24); return (msb << 24) | lsb; } + if( type() == Type::SCMPLUS ) { + return reader_.read(2 * 8, 32); + } if( type() == Type::IDM ) { return reader_.read(5 * 8, 32); } @@ -57,6 +60,9 @@ Consumption Packet::consumption() const { if( type() == Type::SCM ) { return reader_.read(11, 24); } + if( type() == Type::SCMPLUS ) { + return reader_.read(6 * 8, 32); + } if( type() == Type::IDM ) { return reader_.read(25 * 8, 32); } @@ -67,6 +73,9 @@ CommodityType Packet::commodity_type() const { if( type() == Type::SCM ) { return reader_.read(5, 4); } + if( type() == Type::SCMPLUS ) { + return reader_.read(1 * 8 + 4, 4); + } if( type() == Type::IDM ) { return reader_.read(4 * 8 + 4, 4); } @@ -80,7 +89,8 @@ FormattedSymbols Packet::symbols_formatted() const { bool Packet::crc_ok() const { switch(type()) { case Type::SCM: return crc_ok_scm(); - case Type::IDM: return crc_ok_idm(); + case Type::SCMPLUS: + case Type::IDM: return crc_ok_ccitt(); default: return false; } } @@ -95,7 +105,7 @@ bool Packet::crc_ok_scm() const { return ert_bch.checksum() == 0x0000; } -bool Packet::crc_ok_idm() const { +bool Packet::crc_ok_ccitt() const { CRC<16> ert_crc_ccitt { 0x1021, 0xffff, 0x1d0f }; for(size_t i=0; i