Page 1 of 2

ModBus service is not starting correctly after revPI reboot

Posted: 04 Jan 2022, 11:09
by Nils
Hi,

I currently have a problem with the Modbus RTU communication via RS485 on RevPI Connect+.
Internal Serial Number: 012337B763E3D385
Host: Linux RevPi62003 4.19.95-rt38-v7 #1 SMP PREEMPT RT Fri, 03 Dec 2021 13:31:50 +0000 armv7l GNU/Linux
2021-07-01-revpi-buster.img

Modbus communication is not reinititated after restarting the revPI. The service pimodbus-master.service is ENABLED, but after a restart we observe the following error of the daemon:

Dec 29 11:05:32 RevPi62003 systemd[1]: Started Revolution Pi Modbus master.
Dec 29 11:05:32 RevPi62003 piModbusMaster[1553]: piModbusMaster started
Dec 29 11:05:32 RevPi62003 piModbusMaster[1553]: Modbus connection failed: No such file or directory

I believe the revPI is trying to access the device (/dev/ttyRS485) too early, therefore the service is crashing since it has not been initialized. I have resolved the problem by restarting the modbus service manually but I don´t think this is intended behaviour ;)

As a permanent solution I have added 'ExecStartPre=/bin/sleep 5' to '/lib/systemd/system/pimodbus-master.service' right after the ExecStart section, which makes the service wait for 5 seconds and attempts the start afterwards. This works without a problem but I believe it should be fixed in the upstream repos.

Cheers,
Nils

Re: ModBus service is not starting correctly after revPI reboot

Posted: 04 Jan 2022, 11:23
by nicolaiB
Hi Nils,

Yes, this is a bug which occurs with buster. We will publish an updated modbus package soon, which will fix this. For now you can fix this (same as in the upcomming package) by update the unit file as following:

Code: Select all

[Unit]
Description=Revolution Pi Modbus master
Documentation=https://revolution.kunbus.com
After=network.target systemd-modules-load.service dev-ttyRS485.device
Requires=dev-ttyRS485.device

[Service]
ExecStart=/usr/sbin/piModbusMaster
StandardOutput=journal
StandardError=journal
Restart=on-failure

[Install]
WantedBy=multi-user.target
The "Requires" argument makes sure, that the daemon is started after the device is available.

Nicolai

Re: ModBus service is not starting correctly after revPI reboot

Posted: 23 Jan 2022, 10:39
by ostermann
Das erklärt einige meiner Probleme mit der Modbus-Kommunikation. Wo finde ich dieses "unit" file?

Mit freundlichen Grüßen
Thorsten Ostermann

Re: ModBus service is not starting correctly after revPI reboot

Posted: 23 Jan 2022, 11:39
by nicolaiB
Hallo Thorsten,

Das Unit File findet sich unter /lib/systemd/system/pimodbus-master.service (für slave ggf den Namen anpassen).

Das entsprechende offizielle Update wird voraussichtlich nächste Woche über die üblichen Update Kanäle verfügbar sein.

Gruß Nicolai

Re: ModBus service is not starting correctly after revPI reboot

Posted: 23 Jan 2022, 17:36
by ostermann
Hallo Nicolai,

danke, dass habe ich direkt angepasst. Kann es sein, dass man nach jeder Änderung der Modbus-Parameter einen kompletten Reboot des RevPi durchführen muss? Ein Neustart des Treibers für das Prozessabbild scheint da nicht zu reichen? Ich habe mir extra ein Oszilloskop an die Modbus-Leitung gehängt, damit ich direkt sehe ob die Kommunikation läuft oder nicht.

Mit freundlichen Grüßen
Thorsten Ostermann

Re: ModBus service is not starting correctly after revPI reboot

Posted: 23 Jan 2022, 18:51
by Nils
Hi Thorsten,

du kannst den Modbus Service immer nach einem Restart des Treibers mit "systemctl restart pimodbus-master.service" ebenfalls neustarten. Ein Neustart des PI ist nicht nötig. Der Befehl muss mit root Privilegien ausgeführt werden. Danach sollte die Modbus Kommunikation mit den neuen Parametern wieder aufgenommen werden.

Gruß
Nils

Re: ModBus service is not starting correctly after revPI reboot

Posted: 23 Jan 2022, 19:20
by nicolaiB
Hallo zusammen,

Der Hinweis von Niels zum Restart des Daemons passt soweit. Es ist aber vermutlich notwendig die Systemd Konfiguration neu einzulesen (systemctl daemon-reload).

Gruß Nicolai

Re: ModBus service is not starting correctly after revPI reboot

Posted: 29 Jan 2022, 18:04
by ostermann
Es wäre schön, wenn man den ModbusMaster auch über die PiCtory GUI neustarten könnte. Von mir aus am liebsten gemeinsam mit dem Treiber für das Prozessabbild. Falls das aus irgendwelchen Gründen nicht sinnvoll sein sollte, dann eben separat.

Mit freundlichen Grüßen
Thorsten Ostermann

Re: ModBus service is not starting correctly after revPI reboot

Posted: 03 Feb 2022, 16:55
by Joca
Hi guys,

I have that exact problem, with the pimodbus-master.
has a correction been released?

Thanks

Re: ModBus service is not starting correctly after revPI reboot

Posted: 03 Feb 2022, 17:42
by nicolaiB
Hi Joca,

yes the patch has been released last week. Please check if there are updates via apt-get update / upgrade

Nicolai