volkszaehler / vzlogger

Logging utility for various meters & sensors
http://wiki.volkszaehler.org/software/controller/vzlogger
GNU General Public License v3.0
140 stars 122 forks source link

vzlogger has problems getting data from meters after reboot. USB meter replug (!) is necessary. #509

Open magicmil opened 2 years ago

magicmil commented 2 years ago

This startet around begin of November 2021. Using Linux Version: Ubuntu 20.04.3 LTS (always with newest updates) Kernel: 5.4.0-92-generic

After a reboot meter values are only comming very seldom or not at all.

The restart of the service does not suffice. Maybe it is even not necessary. USB Replugging of the meteres is mandatory. Already updated to the newest version of vzlogger at the end of December 2021, which dit not help. Afterwards it runs perfect until the next reboot - which is only needed it updates require it, since it is a 24/7 server. I am using USB device, not port related configuration (see below)

Is it maybe related to a kernel change for the usb-SiliconLabsCP2104_USB_to_UART_Bridge_Controller my 2 meters are using?

Well, seeing all those commits for: https://github.com/torvalds/linux/commits/master/drivers/usb/serial/cp210x.c it seems, as they broke something, when adding GPIO support. Maybe December 14 commit fixes it....

Is it a known issue to vzlogger users? Can I hard reset the controllers or USB config from commandline? I am wondering what a reboot could do less or mix up.

My volkszaehler and vzlogger setup had no problem for years since November 2021. Here is my vzlogger.conf config:

/**

{ "retry" : 30, / how long to sleep between failed requests, in seconds / "daemon": true, / run periodically / "verbosity" : 0, / between 0 and 15 / "log" : "/var/log/vzlogger.log",/ path to logfile, optional /

"local" : { "enabled" : false, / should we start the local HTTPd for serving live readings? / "port" : 85, / the TCP port for the local HTTPd / "index" : true, / should we provide a index listing of available channels? / "timeout" : 30, / timeout for long polling comet requests, 0 disables comet, in seconds / "buffer" : 600 / how long to buffer readings for the local interface, in seconds / },

"meters" : [{ "enabled" : true, "protocol" : "sml", "device" : "/dev/serial/by-id/usb-Silicon_Labs_CP2104_USB_to_UART_Bridge_Controller_00F3247A-if00-port0", "aggtime": 60, "aggfixedinterval": false, "channels": [{ "uuid" : "7c087e70-9f71-11e5-a1ac-4bf832fe27de", "middleware" : "http://server:password@localhost:85/middleware.php", "aggmode": "MAX", "identifier" : "1-0:1.8.1", // Hausstrom Zaehlerstand (Wh) }, { "uuid" : "bcc9aca0-9f83-11e5-a195-d3a6a6707171", "middleware" : "http://server:password@localhost:85/middleware.php", "aggmode": "AVG",
"identifier" : "1-0:1.7.1", // Hausstrom Leistung (Watt) }] },{ "enabled" : true, "protocol" : "sml", "device" : "/dev/serial/by-id/usb-Silicon_Labs_CP2104_USB_to_UART_Bridge_Controller_00F31C2A-if00-port0", "aggtime": 60, "aggfixedinterval": false, "channels": [{ "uuid" : "d3273de0-a28c-11e5-8b21-f97c0c7dd262", "middleware" : "http://server:password@localhost:85/middleware.php", "aggmode": "MAX", "identifier" : "1-0:1.8.1", // Wärmepumpe Zaehlerstand (Wh) },{ "uuid" : "a979cb30-a28c-11e5-b498-978c6272f141", "middleware" : "http://server:password@localhost:85/middleware.php", "aggmode": "AVG", "identifier" : "1-0:1.7.1", // Wärmepumpe Leistung (Watt) }] } ]}

r00t- commented 2 years ago

hard to imagine anything in vzlogger causing this. a kernel/driver bug seems much more likely. some port power control is possible in linux, but i don't know if the raspberry pi's ports support it. maybe an extra hub would. (might add a pointer to details later.) i'd suggest power-cycling (instead of just rebooting) on updates as a workaround, as this is something that can be planned.

gr8bit commented 1 year ago

@magicmil I have the same issue and in my case it's vzlogger being unable to open the device when my Pi boots. When I restart vzlogger (sudo systemctl restart vzlogger) after booting, the device is there and vzlogger starts. Were you able to solve that problem?

magicmil commented 1 year ago

Unfortunately not :(Am 06.11.2022 20:21 schrieb Niklas Bichinger @.***>: @magicmil I have the same issue and in my case it's vzlogger being unable to open the device when my Pi boots. When I restart vzlogger (sudo systemctl restart vzlogger) after booting, the device is there and vzlogger starts. Were you able to solve that problem?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

gr8bit commented 1 year ago

I fixed my problem by making the vzlogger service restart when it quits. This way, it will fail once on start because the /dev/ttyUSB0 isn't there and then becomes restarted after 30 seconds and succeeds because the device is there.

In file /etc/systemd/system/vzlogger.service, add Restart and RestartSec directives:

[Service]
...
Restart=always
RestartSec=30

Maybe that helps you as well.

r00t- commented 1 year ago

@gr8bit:
in your case you probably need some dependency in the systemd file to delay the start of vzlogger until the device is available... i wouldn't know how exactly, something with udev?