From 0ecd4fed8325b1ee2afdc44894df52fcd754373f Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 2 Dec 2019 13:29:43 -0800 Subject: [PATCH] wmr200: Discard packets with 'interval' of zero (#472) Packets with pc adjusted time that occur after the startup timestamp but before the minimal interval expected (60 seconds) produce an interval of 0. Issue: 375 --- bin/weewx/drivers/wmr200.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/weewx/drivers/wmr200.py b/bin/weewx/drivers/wmr200.py index 68801898..0b4562fc 100644 --- a/bin/weewx/drivers/wmr200.py +++ b/bin/weewx/drivers/wmr200.py @@ -1957,13 +1957,24 @@ class WMR200(weewx.drivers.AbstractDevice): weeutil.weeutil.timestamp_to_string( pkt.timestamp_record()))) elif pkt.timestamp_record() > since_ts: - # Calculate the rain accumulation between valid archive + # Update the timestamp delta previous value even if + # we do not use this packet. This is so the next archive + # packet, if any, has the proper delta timestamp + # calculation. + timestamp_packet_previous = timestamp_packet_current + + # Ensure that the packet has a valid 'interval' field. + packet_record_interval = int(timestamp_packet_interval / 60.0) + if packet_record_interval == 0: + # This packet occurred less than the minimal interval after the + # initial time search space and is discarded. + loginf('genStartup() Discarding received archive record' + ' since interval is zero') + return + pkt.record_update({'interval': packet_record_interval}) + # Calculate the rain accumulation between valid archive # packets. pkt.record_update(adjust_rain(pkt, PacketArchiveData)) - # Ensure that the packet has a valid 'interval' field - pkt.record_update({'interval': int(timestamp_packet_interval / 60.0)}) - - timestamp_packet_previous = timestamp_packet_current cnt += 1 logdbg(('genStartup() Yielding received archive' ' record cnt:%d after requested timestamp'