thiagoralves / OpenPLC_v3

OpenPLC Runtime version 3
1.06k stars 432 forks source link

[development] modbusslave service is not started #158

Closed vembacher closed 2 years ago

vembacher commented 2 years ago

Issue

The modbusslave service is not started at all. It is turned on in the settings and the uploaded PLC program contains variables that are mapped to addresses in the range of the server. Port scanning shows that the port is not listening. Has the behavior changed somehow compared to the main branch? So far I've never had this issue there. I'm working with the development branch because I'm working on adding OPC UA server support (will most likely open an issue about this to track progress).

Context

Logs

Logs on dashboard:

[2021-10-19 16:55:29.744] [info] OpenPLC Runtime starting...
[2021-10-19 16:55:29.744] [info] Config file ../etc/config.ini could not be read
[2021-10-19 16:55:29.744] [info] Skipped load persistence because file cannot be read.
[2021-10-19 16:55:29.744] [info] Setting main thread priority to RT
[2021-10-19 16:55:29.744] [info] Locking main thread memory
[2021-10-19 16:55:29.745] [info] Starting service interactive
[2021-10-19 16:55:29.748] [info] Starting service modbusmaster
[2021-10-19 16:55:29.751] [info] Interactive Server: Listening on port 43628

webserver

opening /monitoring causes internal server error with the following issue:

[2021-10-19 17:02:22,536] ERROR in app: Exception on /monitor-update [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "webserver.py", line 1401, in monitor_update
    monitor.start_monitor()
  File "/workdir/webserver/monitoring.py", line 137, in start_monitor
    modbus_monitor()
  File "/workdir/webserver/monitoring.py", line 72, in modbus_monitor
    result = mb_client.read_input_registers(int(mb_address), 1)
  File "/usr/local/lib/python3.7/dist-packages/pymodbus/client/common.py", line 125, in read_input_registers
    return self.execute(request)
  File "/usr/local/lib/python3.7/dist-packages/pymodbus/client/sync.py", line 105, in execute
    raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(127.0.0.1:502)]

As we can see it cannot connect to the modbus server at all, not even.

Cause

So far I have not found the cause of the issue. I will take a look at it and hopefully find the cause, but I'm somewhat limited on time I can expend for this, so if anyone else knows any possible cause we can try to track it down together.

thiagoralves commented 2 years ago

I suggest you work on the master branch. Development branch has some planned features that never reached the end of development, so it is considered broken for now.

On Tue, Oct 19, 2021 at 1:16 PM vembacher @.***> wrote:

Issue

The modbusslave service is not started at all. It is turned on in the settings and the uploaded PLC program contains variables that are mapped to addresses in the range of the server. Port scanning shows that the port is not listening. Has the behavior changed somehow compared to the main branch? So far I've never had this issue there. I'm working with the development branch because I'm working on adding OPC UA server support (will most likely open an issue about this to track progress). Context

  • I'm using commit 6bbd69b on branch development from a freshly cloned repo.
  • I'm running it inside a docker container, build using the Dockerfile from the repo and appropriate capabilities.

Logs Logs on dashboard:

[2021-10-19 16:55:29.744] [info] OpenPLC Runtime starting... [2021-10-19 16:55:29.744] [info] Config file ../etc/config.ini could not be read [2021-10-19 16:55:29.744] [info] Skipped load persistence because file cannot be read. [2021-10-19 16:55:29.744] [info] Setting main thread priority to RT [2021-10-19 16:55:29.744] [info] Locking main thread memory [2021-10-19 16:55:29.745] [info] Starting service interactive [2021-10-19 16:55:29.748] [info] Starting service modbusmaster [2021-10-19 16:55:29.751] [info] Interactive Server: Listening on port 43628

webserver

opening /monitoring causes internal server error with the following issue:

[2021-10-19 17:02:22,536] ERROR in app: Exception on /monitor-update [GET] Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.7/dist-packages/flask/_compat.py", line 35, in reraise raise value File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "webserver.py", line 1401, in monitor_update monitor.start_monitor() File "/workdir/webserver/monitoring.py", line 137, in start_monitor modbus_monitor() File "/workdir/webserver/monitoring.py", line 72, in modbus_monitor result = mb_client.read_input_registers(int(mb_address), 1) File "/usr/local/lib/python3.7/dist-packages/pymodbus/client/common.py", line 125, in read_input_registers return self.execute(request) File "/usr/local/lib/python3.7/dist-packages/pymodbus/client/sync.py", line 105, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(127.0.0.1:502)]

As we can see it cannot connect to the modbus server at all, not even. Cause

So far I have not found the cause of the issue. I will take a look at it and hopefully find the cause, but I'm somewhat limited on time I can expend for this, so if anyone else knows any possible cause we can try to track it down together.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/thiagoralves/OpenPLC_v3/issues/158, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB63XPH7LFPTAT42BANFXXTUHWRWLANCNFSM5GJVLGHA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

vembacher commented 2 years ago

Oh, that's unfortunate. I'll need to re-write some code now.

How broken is the development branch?

thiagoralves commented 2 years ago

I don't know... I haven't tried it in ages. All of my code always go to the master branch

On Tue, Oct 19, 2021 at 2:08 PM vembacher @.***> wrote:

Oh, that's unfortunate. I'll need to re-write some code now.

How broken is the development branch?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thiagoralves/OpenPLC_v3/issues/158#issuecomment-946974308, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB63XPFFFMPXE4CXHAOINS3UHWXZVANCNFSM5GJVLGHA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

vembacher commented 2 years ago

actually I should not close this, the issue still exists. :sweat_smile: