Hi Tom,

You don’t need to restart or try a wake up.  You just need to return from 
genDavisLoopPackets so another request is made for packets.

Below is what I have been running.  You can simplify it as the bad_read 
variable is not necessary since it has NEVER occurred that two bad reads 
happened in a row.  Returning from genDavisLoopPackets on this error always 
results in the next read working (of course, the loop command is reissued first 
since genDavisLoopPackets is called again).

I have never sent this change because I’m running a copy of the vantage driver 
with many other changes.  If the excerpts below don’t make sense, you can see 
the whole driver at: https://github.com/chaunceygardiner/weewx-vantagenext

Declare an exception:        
class ShortReadIOError(weewx.WeeWxIOError):
    """Exception raised when too few bytes read from serial port."""

In read, raise the exception if too few bytes are read:
        N = len(_buffer)
        if N != chars:
            raise ShortReadIOError("Expected %d chars; got %d" % (chars, N))

And, in genDavisLoopPackets, catch the ShortReadIOError and simply return:
               try:
                    loop_packet = self._get_packet()
                    log.debug('%s: Loop packet success!' % 
weeutil.weeutil.timestamp_to_string(loop_packet['dateTime']))
                except ShortReadIOError as e:
                    log.info('get_packet: %s. (%d)' % (e, self.pkt_count))
                    # If already on a bad read, log that fact.
                    if self.on_bad_read:
                        log.info('genDavisLoopPackets: repeated bad read.')
                    self.on_bad_read = True
                    return
                except weewx.WeeWxIOError as e:
                    log.error("LOOP try #%d; error: %s", count + 1, e)
                    time.sleep(self.port.wait_before_retry)
                else:
                    self.on_bad_read = False
                    self.pkt_count += 1
                    yield loop_packet
                    break

> On May 8, 2022, at 2:02 PM, Tom Keffer <[email protected]> wrote:
> 
> Now that I think about it, there is an experiment I've been meaning to try. 
> Right now, the Vantage driver tries 3 times, then gives up and restarts the 
> program from the top.
> 
> The experiment would be to do something not quite so drastic. Rather than 
> restart the program, try a Vantage "wake up" sequence instead.
> 
> I've never tried this strategy because there hasn't been a logger regularly 
> showing this error that I could test. But it appears yours does. I'm tied up 
> with something else, but give me a few days to come up with a solution.
> 
> In the meantime, I've posted issue #772.
> 
> On Sun, May 8, 2022 at 1:03 PM Dave McCreath <[email protected]> wrote:
>> Spoke too soon.  The error appears to back back up, is this a data logger 
>> issue?:
>> 
>> May  8 20:55:18 raspberrypi weewx[8172] INFO weewx.restx: AWEKAS: Published 
>> record 2022-05-08 20:55:00 BST (1652039700)
>> May  8 20:55:18 raspberrypi weewx[8172] INFO weewx.restx: PWSWeather: 
>> Published record 2022-05-08 20:55:00 BST (1652039700)
>> May  8 20:55:18 raspberrypi weewx[8172] INFO weewx.restx: Wunderground-PWS: 
>> Published record 2022-05-08 20:55:00 BST (1652039700)
>> May  8 20:55:19 raspberrypi weewx[8172] INFO weewx.cheetahgenerator: 
>> Generated 8 files for report SeasonsReport in 1.07 seconds
>> May  8 20:55:21 raspberrypi weewx[8172] INFO weewx.imagegenerator: Generated 
>> 30 images for report SeasonsReport in 2.44 seconds
>> May  8 20:55:21 raspberrypi weewx[8172] INFO weewx.reportengine: Copied 0 
>> files to /var/www/html/weewx
>> May  8 20:55:28 raspberrypi weewx[8172] ERROR weewx.drivers.vantage: LOOP 
>> try #1; error: Expected to read 99 chars; got 0 instead
>> May  8 20:55:32 raspberrypi weewx[8172] ERROR weewx.drivers.vantage: LOOP 
>> try #2; error: Expected to read 99 chars; got 0 instead
>> May  8 20:55:36 raspberrypi weewx[8172] ERROR weewx.drivers.vantage: LOOP 
>> try #3; error: Expected to read 99 chars; got 0 instead
>> May  8 20:55:40 raspberrypi weewx[8172] ERROR weewx.drivers.vantage: LOOP 
>> try #4; error: Expected to read 99 chars; got 0 instead
>> May  8 20:55:40 raspberrypi weewx[8172] ERROR weewx.drivers.vantage: LOOP 
>> max tries (4) exceeded.
>> May  8 20:55:40 raspberrypi weewx[8172] INFO weewx.engine: Main loop 
>> exiting. Shutting engine down.
>> May  8 20:55:40 raspberrypi weewx[8172] INFO weewx.engine: Shutting down 
>> StdReport thread
>> May  8 20:55:40 raspberrypi weewx[8172] CRITICAL __main__: Caught 
>> WeeWxIOError: Max tries exceeded while getting LOOP data.
>> May  8 20:55:40 raspberrypi weewx[8172] CRITICAL __main__:     ****  Waiting 
>> 60 seconds then retrying...
>> May  8 20:56:40 raspberrypi weewx[8172] INFO __main__: retrying...
>> May  8 20:56:40 raspberrypi weewx[8172] INFO __main__: Using configuration 
>> file /etc/weewx/weewx.conf
>> May  8 20:56:40 raspberrypi weewx[8172] INFO __main__: Debug is 0
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Loading station 
>> type Vantage (weewx.drivers.vantage)
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: StdConvert target 
>> unit is 0x1
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Archive will use 
>> data binding wx_binding
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Record generation 
>> will be attempted in 'software'
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Using archive 
>> interval of 300 seconds (software record generation)
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.restx: StationRegistry: 
>> Station will not be registered: no station_url specified.
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.restx: Wunderground-PWS: 
>> Data for station ICAMBSLE2 will be posted
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.restx: PWSWeather: Data 
>> for station WISBECH will be posted
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.restx: CWOP: Posting not 
>> enabled.
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.restx: WOW: Posting not 
>> enabled.
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.restx: AWEKAS: Data will 
>> be uploaded for user DMacWx
>> May  8 20:56:40 raspberrypi weewx[8172] INFO __main__: Starting up weewx 
>> version 4.5.1
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Clock error is 
>> 0.55 seconds (positive is fast)
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Using binding 
>> 'wx_binding' to database 'weewx.sdb'
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.manager: Starting 
>> backfill of daily summaries
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.manager: Daily summaries 
>> up to date
>> May  8 20:56:40 raspberrypi weewx[8172] INFO weewx.engine: Starting main 
>> packet loop.
>> May  8 21:00:16 raspberrypi weewx[8172] INFO weewx.manager: Added record 
>> 2022-05-08 21:00:00 BST (1652040000) to database 'weewx.sdb'
>> May  8 21:00:16 raspberrypi weewx[8172] INFO weewx.manager: Added record 
>> 2022-05-08 21:00:00 BST (1652040000) to daily summary in 'weewx.sdb'
>> May  8 21:00:16 raspberrypi weewx[8172] INFO weewx.restx: AWEKAS: Published 
>> record 2022-05-08 21:00:00 BST (1652040000)
>> May  8 21:00:16 raspberrypi weewx[8172] INFO weewx.restx: PWSWeather: 
>> Published record 2022-05-08 21:00:00 BST (1652040000)
>> May  8 21:00:16 raspberrypi weewx[8172] INFO weewx.restx: Wunderground-PWS: 
>> Published record 2022-05-08 21:00:00 BST (1652040000)
>> May  8 21:00:17 raspberrypi weewx[8172] INFO weewx.cheetahgenerator: 
>> Generated 8 files for report SeasonsReport in 1.02 seconds
>> May  8 21:00:21 raspberrypi weewx[8172] INFO weewx.imagegenerator: Generated 
>> 45 images for report SeasonsReport in 4.30 seconds
>> May  8 21:00:21 raspberrypi weewx[8172] INFO weewx.reportengine: Copied 5 
>> files to /var/www/html/weewx
>> 
>> Any suggestions welcome.
>> 
>> Dave
>> 
>> On Sunday, 8 May 2022 at 20:20:45 UTC+1 Dave McCreath wrote:
>>> Just noticed a couple of errors thrown up by WeeWX:
>>> 
>>> ERROR weewx.drivers.vantage: LOOP try #1; error: Expected to read 99 chars; 
>>> got 0 instead.
>>> Having then read through this forum I then reset the data logger in the 
>>> Vantage console (removed all power, pulled the data logger out for 20 
>>> seconds, replaced and then powered back up) and all appears to be back up 
>>> and running OK.
>>> 
>>> My first data logger lasted about 5 years before giving up on me, this one 
>>> is about 3 years old, is this a sign that it's on its way out as well?
>>> 
>>> They're not cheap!
>>> 
>>> 
>>> 
>>> Thanks
>>> 
>>> 
>>> 
>>> Dave
>>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/9244ee2d-e630-4fd1-ae09-96e5815c52f8n%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/weewx-user/CAPq0zEDik39%2BLEOGTnrcMAtW3CorRJqUiGe_96iVFszAm53gbA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/D2A80355-C607-40DC-803C-813ACB968BB4%40johnkline.com.

Reply via email to