Service restarts on GW1000 loss

87 views
Skip to first unread message

Seth Ratner

unread,
Dec 22, 2021, 7:21:51 PM12/22/21
to weewx-user
Hi everyone.

I have WeeWX set up on a Raspberry Pi with the GW1000 driver. I'm also using a service I wrote to add a wired rain gauge to the GPIO pins using the gpiozero library.


The setup is on the bitter edge of a wifi network, so the components drop in and out of the connection. When the GW1000 drops out, WeeWX tries three times to query it, then seems to shutdown the loop:

ERROR user.gw1000: Unable to obtain live sensor data
INFO weewx.engine: Main loop exiting. Shutting engine down.
INFO weewx.engine: Shutting down StdReport thread
DEBUG weewx.engine: StdReport thread has been terminated
INFO user.gw1000: Gw1000Collector thread has been terminated
CRITICAL __main__: Caught WeeWxIOError: Failed to obtain response to command 'CMD_GW1000_LIVEDATA' after 3 attempts
CRITICAL __main__:     ****  Waiting 60 seconds then retrying...


It then goes through the whole process of launching the engine. When it gets to my service:

DEBUG weewx.engine: Loading service user.gpio_rain_service.GpioRainGauge

The service throws an error when it tries to reinitialize the GPIO pin. The pin is still set in gpiozero from before the loop exited, and you can't set a pin twice. 

How can I make my service run the close() process when the main loop is exited? This would free up the pin to be reassigned when the loop restarts.

Thanks!

Tom Keffer

unread,
Dec 22, 2021, 7:43:21 PM12/22/21
to weewx-user
The class StdService has a stub method shutDown() that is called when the engine stops. Just override it and run close().

--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/6fbe0d9b-1df1-46df-8862-645dfd0fc04an%40googlegroups.com.

Seth Ratner

unread,
Dec 22, 2021, 10:09:26 PM12/22/21
to weewx-user
Awesome, thanks!
Message has been deleted

Tom Keffer

unread,
Dec 23, 2021, 7:28:22 AM12/23/21
to weewx-user
The function shutDown() will be called automatically.

On Wed, Dec 22, 2021 at 7:47 PM Seth Ratner <lordr...@gmail.com> wrote:
Do I need to bind the ShutDown() method in my service to something, or will ShutDown() be called automatically in all services based on the StdService class?

Thanks again

On Wednesday, December 22, 2021 at 6:43:21 PM UTC-6 tke...@gmail.com wrote:

Seth Ratner

unread,
Dec 23, 2021, 12:21:35 PM12/23/21
to weewx-user
Ugh, I had "ShutDown" in my script instead of "shutDown"

Thanks again, the more I dig through the WeeWX code, the more impressed I am. 
Reply all
Reply to author
Forward
0 new messages