Skip to content

Commit 9faf18e

Browse files
committed
Fix offsets for block CRCs
1 parent 500f23d commit 9faf18e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/devices/m_bus.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,15 @@ static int parse_block2(const m_bus_data_t *in, m_bus_block1_t *block1)
784784
b2->ST = b[5];
785785
b2->CW = (b[9] << 8) | (b[8]);
786786
b2->pl_offset = BLOCK1A_SIZE - 2 + 8;
787-
b2->q_total = ((uint32_t)b[20] << 24) | (b[19] << 16) | (b[18] << 8) | (b[17]);
788-
b2->q_lastyear = ((uint32_t)b[26] << 24) | (b[25] << 16) | (b[24] << 8) | (b[23]);
789-
b2->q_lastmonth = ((uint32_t)b[32] << 24) | (b[31] << 16) | (b[30] << 8) | (b[29]);
787+
// Note the offsets to skip block CRCs
788+
b2->q_total = ((uint32_t)b[20+2] << 24) | (b[19+2] << 16) | (b[18+2] << 8) | (b[17+2]);
789+
b2->q_lastyear = ((uint32_t)b[26+2] << 24) | (b[25+2] << 16) | (b[24+2] << 8) | (b[23+2]);
790+
b2->q_lastmonth = ((uint32_t)b[32+4] << 24) | (b[31+2] << 16) | (b[30+2] << 8) | (b[29+2]);
790791
if (block1->A_DevType == 6) {
791792
/* WarmWater */
792793
}
793794
if (block1->A_DevType == 8) {
795+
/* Heat Cost Allocator */
794796
// snprintf(extra, sizeof(extra), "%02x%02x%02x%02x%02x", b[6], b[7], b[8], b[9], b[10]);
795797
}
796798
}

0 commit comments

Comments
 (0)