count INVALID_MSG_FMT errors

This commit is contained in:
Stefan Allius
2024-03-31 00:26:54 +01:00
parent 7cbd5f25bb
commit 643c0026d8
2 changed files with 5 additions and 0 deletions

View File

@@ -153,6 +153,7 @@ class SolarmanV5(Message):
self.snr = result[4]
if start != 0xA5:
self.inc_counter('Invalid_Msg_Format')
return
self.header_valid = True
return
@@ -161,11 +162,13 @@ class SolarmanV5(Message):
crc = buf[self.data_len+11]
stop = buf[self.data_len+12]
if stop != 0x15:
self.inc_counter('Invalid_Msg_Format')
return False
check = sum(buf[1:buf_len-2]) & 0xff
if check != crc:
logger.debug(f'CRC {int(crc):#02x} {int(check):#08x}'
f' Stop:{int(stop):#02x}')
self.inc_counter('Invalid_Msg_Format')
return False
return True