PLCNEXT#Let’s use PyPlcnextRsc_Part1

RSC is Remote Service Calls and communicates between PLCNEXT’s Process and devices. The RSC Service can be used in the following areas:

  • Axioline services
    • Axioline device data read/write
  • PROFINET services
    • Read/write data for Profinet devices
  • Device Interface services
    • Information access to operating system and controller hardware
  • GDS services
    • Global Data Space (GDS) data read/write

 

PyPlcnextRsc Installation

You can install the Python version of the Rsc Service library with the following command.

PyPLCnextRsc is a simple RSC Client library that allows you to use the RSC Service from Python.(Note that this packge is still under development and does not have 100% functionality.)

pip install -U pyplcnextrsc

Documents

https://pyplcnextrsc.readthedocs.io/en/latest/index.html

Reference Link

http://soup01.com/en/category/phoenixcontact/plcnext_en/

Edit the RscGatway.settings

This Package has a Default TLS Socket, but it is a bit of a pain to set up, so I will try to access it without TLS.RscGatway.settings must be modified for this purpose.

cd /etc/plcnext/device/System/RscGateway/
nano RscGatway.settings

Message File ‘RscGateway.settings’ is unwriteable is shown.

Now try Admin rights with sudo.

sudo nano RscGatway.settings

user admin is not allowed to execute… as root on axcf2152.So, if you are root, you have editing privileges.


Change Root Password

Change the root password with the following command.

sudo passwd root

Enter your New password.

Retype the new password.

Password modification is done.

Login as root

Login as root.

su root

You logined as root@axcf2152.

Modify the RscGatway.settings again.

nano RscGatway.settings

Done!

Gateways></Gateways>, there is a description of <TcpGatewaySettings …>.

Add the following statement below it to open port 41111 without TLS. 

Save the File and restart PLCENXT.

<TcpGatewaySettings gatewayId=”2″ tcpPort=”41111″ sessionTimeout=”300000″ encrypted=”false” />

Example1

This is Example 1. It is almost the same as the Code described in the document.

In order to create ExtraConfigure(), it is necessary to create and pass another Configuration for PyPlcnextRsc’s Device Object because the Default is TLS enabled. Therefore, there is a conf.useTls = False statement.

Next, secureInfoSupplier=ConsoleSupplierExample requires Login to use PlcnextRsc. Of course, secureInfoSupplier = lambda:(“admin”, “my_pass”) like this is fine, but basically Password is not written in the code.

There are two types of ConsoleSupplierExample and GUISupplierExample in the library, which provide an Example that can work with Login.

from PyPlcnextRsc import Device,GUISupplierExample,ConsoleSupplierExample,ExtraConfigure
from PyPlcnextRsc.Arp.Plc.Domain.Services import IPlcManagerService, PlcStartKind

conf = ExtraConfigure()
conf.useTls = False
with Device(‘192.168.3.2’, secureInfoSupplier=ConsoleSupplierExample, port=41111, config=conf) as device:
print(“Device is connected!”)

When you execute the code, you will be asked to enter a UserName.

Enter admin as the user name.

Enter your password.

Done!The connection is established if “Device is connected!” is shown.

Example2

Not much different from Example 1, just changed secureInfoSupplier=GUISupplierExample.

from PyPlcnextRsc import Device,GUISupplierExample,ConsoleSupplierExample,ExtraConfigure
from PyPlcnextRsc.Arp.Plc.Domain.Services import IPlcManagerService, PlcStartKind

conf = ExtraConfigure()
conf.useTls = False

with Device(‘192.168.3.2’, secureInfoSupplier=GUISupplierExample, port=41111, config=conf) as device:
    print(‘Device is connected..’)

Error:Your Python doesn’t have tkinter for GUI

If you get this error when running Code, you must first install tkinter.

Error :Your Python doesn’t have tkinter for GUI

Please run this command:

sudo apt-get install python3-tk

Do you want to continue?Y.

just a while…

Run again

This time, UserName and Password will be the screen to Login.

If the message “Device is connected…” appears, the connection was successful. 

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする