From ea9fe134a242ddd0ea1df9e1c4aa4ddea1542ff6 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Sat, 15 Sep 2018 05:48:46 -0700 Subject: [PATCH] Guard against a negative value for 'interval' in WMR200 stations. --- bin/weewx/drivers/wmr200.py | 7 ++++++- docs/changes.txt | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/weewx/drivers/wmr200.py b/bin/weewx/drivers/wmr200.py index 24183f55..b0046c3d 100644 --- a/bin/weewx/drivers/wmr200.py +++ b/bin/weewx/drivers/wmr200.py @@ -1943,7 +1943,12 @@ class WMR200(weewx.drivers.AbstractDevice): timestamp_packet_interval = timestamp_packet_current \ - timestamp_packet_previous - if pkt.timestamp_record() > (timestamp_packet_previous + if timestamp_packet_interval < 0: + loginf(('genStartup() Discarding received archive record that presented out-of-order; ' + 'current timestamp:%s; previous timestamp:%s') + % (weeutil.weeutil.timestamp_to_string(timestamp_packet_current), + weeutil.weeutil.timestamp_to_string(timestamp_packet_previous))) + elif pkt.timestamp_record() > (timestamp_packet_previous + self._archive_threshold): loginf(('genStartup() Discarding received archive' ' record exceeding archive interval cnt:%d' diff --git a/docs/changes.txt b/docs/changes.txt index f63d3941..cc7bf50d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -29,6 +29,8 @@ doing a merge to the new config file. Fixes issue #217. Example xstats now includes tags for last_year and last_year_todate. Thanks to user evilbunny2008. PR #325. +Guard against a negative value for 'interval' in WMR200 stations. + 3.8.2 08/15/2018