ModBus service is not starting correctly after revPI reboot

Für Themen rund um das Prozessabbild des RevPi Core
Nils
Posts: 15
Joined: 01 Jan 2022, 21:09
Answers: 0

ModBus service is not starting correctly after revPI reboot

Post 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
User avatar
nicolaiB
KUNBUS
Posts: 869
Joined: 21 Jun 2018, 10:33
Answers: 7
Location: Berlin
Contact:

Re: ModBus service is not starting correctly after revPI reboot

Post 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
User avatar
ostermann
Posts: 36
Joined: 11 Dec 2021, 14:51
Answers: 0

Re: ModBus service is not starting correctly after revPI reboot

Post by ostermann »

Das erklärt einige meiner Probleme mit der Modbus-Kommunikation. Wo finde ich dieses "unit" file?

Mit freundlichen Grüßen
Thorsten Ostermann
--
https://www.mechapro.de - Wir bewegen Ihre Ideen!
User avatar
nicolaiB
KUNBUS
Posts: 869
Joined: 21 Jun 2018, 10:33
Answers: 7
Location: Berlin
Contact:

Re: ModBus service is not starting correctly after revPI reboot

Post 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
User avatar
ostermann
Posts: 36
Joined: 11 Dec 2021, 14:51
Answers: 0

Re: ModBus service is not starting correctly after revPI reboot

Post 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
--
https://www.mechapro.de - Wir bewegen Ihre Ideen!
Nils
Posts: 15
Joined: 01 Jan 2022, 21:09
Answers: 0

Re: ModBus service is not starting correctly after revPI reboot

Post 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
User avatar
nicolaiB
KUNBUS
Posts: 869
Joined: 21 Jun 2018, 10:33
Answers: 7
Location: Berlin
Contact:

Re: ModBus service is not starting correctly after revPI reboot

Post 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
User avatar
ostermann
Posts: 36
Joined: 11 Dec 2021, 14:51
Answers: 0

Re: ModBus service is not starting correctly after revPI reboot

Post 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
--
https://www.mechapro.de - Wir bewegen Ihre Ideen!
Joca
Posts: 14
Joined: 24 Aug 2021, 17:41
Answers: 0

Re: ModBus service is not starting correctly after revPI reboot

Post by Joca »

Hi guys,

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

Thanks
User avatar
nicolaiB
KUNBUS
Posts: 869
Joined: 21 Jun 2018, 10:33
Answers: 7
Location: Berlin
Contact:

Re: ModBus service is not starting correctly after revPI reboot

Post by nicolaiB »

Hi Joca,

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

Nicolai
Post Reply