Unmesh
Hello Community,

First of all thank you @thiagoralves for developing such a great open platform. 

I recently came across OpenPLC Editor, Runtime and Scadabr and managed to install on Ubuntu v18.04 

Wrote a simple AND operator and compiled successfully using Runtime. 

First time launching Runtime on local machine was as expected but soon I've started encountering issue "socket.error: [Errno 98] Address already in use"". 

Details-

mj@mj-AM1M-S2H:~/OpenPLC_v3$ ./ start_openplc.sh
* Serving Flask app "webserver" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "webserver.py", line 2348, in <module>
app.run(debug=False, host='0.0.0.0', threaded=True, port=8000)
File "/home/mj/.local/lib/python2.7/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/home/mj/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 1052, in run_simple
inner()
File "/home/mj/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 1005, in inner
fd=fd,
File "/home/mj/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 848, in make_server
host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
File "/home/mj/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 740, in __init__
HTTPServer.__init__(self, server_address, handler)
File "/usr/lib/python2.7/SocketServer.py", line 420, in __init__
self.server_bind()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.7/SocketServer.py", line 434, in server_bind
self.socket.bind(self.server_address)
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use

I did check the port and it seems "Python2.7" is using tcp connection. Killed the process using ID but when I check the port again, "Python2.7" is still active but process ID has changed. Very frustrating indeed.

Simply to put, Runtime is always active locally without initiating start command. Sources under Monitoring section are automatically pulled from previous configurations with Scadabr. Seems no way to delete.

Removed all installations including python2.7 and reinstalled, but the issue still persists. 

I also pulled Scadabr as per instructions to see the program output.

When I setup Data Source "Modbus IP" I receive error as below.

Note : PLC status is running with the AND program.

Screenshot from 2020-04-20 16-47-27.png   
Slave configuration-

Screenshot from 2020-04-20 16-54-13.png

Screenshot from 2020-04-20 17-18-53.png 
Hope I am able to point the issue clearly. Thank you again!
Quote 0 0
thiagoralves
Hi Unmesh, welcome to the forum. It seems that you have a few misconceptions on how an ICS/SCADA system actually works, and more importantly, how OpenPLC works. So here are a few observations to help you out:

1) OpenPLC is installed as a service, which means that once it is installed, the Linux operating system does its best to keep it running all the time. That's why when you kill the process, another comes right up. You can control the OpenPLC service behavior (and any other service process on Linux actually) using the command
sudo systemctl

So for example, if you need to check if OpenPLC Runtime is running you type:
sudo systemctl status openplc

If you want to stop OpenPLC Runtime from running temporarily you type:
sudo systemctl stop openplc

And finally if you want to disable (remove service forever... i.e. it will never run again until you enable it back) OpenPLC Runtime service you type:
sudo systemctl disable openplc

You were never supposed to launch the ./ start_openplc.sh command. In fact, there isn't a place in the instructions that tells you to do that. This script is to be used only by the service daemon.

2) Your ScadaBR setup is messed up. Using 0.0.0.0 as IP address is never going to work. 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target. It doesn't make sense to use this address if you want ScadaBR to reach OpenPLC. What you need to use instead, is the IP address of the machine running OpenPLC. If OpenPLC and ScadaBR are running on the same machine, then you can use 127.0.0.1 which is the localhost address. Additionally, drop the extra :8000 port number parameter (I don't know where you got this). There is a specific field for you to insert the port number which is right below the "Host" field. The right value to put in there is 502 (which is already there). That's the default port used by Modbus, and that's how ScadaBR is going to reach OpenPLC. Finally, your update period is set to 5 minutes, which means you will have to wait a whole 5 minutes period to see something changing. If you want quicker updates, I recommend you changing that to something like 500 milliseconds or maybe 1 second.

3) The Monitoring section has nothing to do with ScadaBR. That page is used for you to monitor your program. It will display all your located variables (%QX0.0, %IX0.0, etc) and will change according to the program you have uploaded.

4) Why are you adding a slave device? From the 0.0.0.0:9090 IP address (which is also incorrect by the way) I imagine you're trying to add ScadaBR as a slave device of the OpenPLC. If that's the case, this is completely wrong. You don't add the Scada software as a slave of the PLC, it is the other way around. The Scada software is the master that pulls data from all slave PLCs. The configuration you are doing on ScadaBR to add a new data source is exactly to setup a slave PLC where to pull data from. You should use the "Slave Devices" functionality on OpenPLC only if you want to expand your I/O ports, adding for example, an Arduino board or another type of Modbus slave device.

In summary, don't worry about starting OpenPLC, it will start itself automatically. Fix the IP address on the ScadaBR configuration, remove all slave devices from the OpenPLC runtime, and you should be good.
Quote 1 0
Unmesh
Hello Thiago,

I really appreciate your prompt and honest response. It really helped to connect scadabr and runtime to see the simple output.

1) One of the software I used required start command to initiate service locally. It was an assumption that even runtime start and stop similarly, thank you for the clarity.

2) I Attempted to connect using local ip but due to horrible scada configuration, it was never meant to work. 

3) About Monitoring, it somehow displayed old installation variables, but its all good, they no longer visible.

4) Never meant to use scada as slave, it was desperate move to see connect runtime and a bad one. Mashed up all the instructions, should have been more logical on that part. 

I'm not a developer but curious to explore and make things work using this open platform. Hoping to learn enough to contribute, cheers!
 
Quote 0 0
thiagoralves
That's great. Perhaps it would be easier if you just start reading the tutorials on the REFERENCE menu of the OpenPLC website: https://www.openplcproject.com/reference
Try at least following the "Creating your first project" tutorial. This will give you a clear view of what the OpenPLC platform is.
Quote 0 0
Unmesh
sounds good, will go through them and try hands on.
Quote 0 0