CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Thu Jan 17, 2019 3:01 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Dec 18, 2018 6:36 am 
Offline
Frequent User
Frequent User

Joined: Thu Mar 17, 2016 1:24 pm
Posts: 120
Hi. In FAQ there is nice manual how to change Modbus TCP Slave network settings from IEC-code:
https://faq.codesys.com/display/CDSFAQ/ ... IP+Address

Is this same way to change Ethernet adapter settings? (IP, mask, gateway)
I mean, settings for component IoDrvEthernet.


Top
   
PostPosted: Tue Dec 18, 2018 8:11 am 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 75
In this exemple you should find how to get it (may be the same lib to set it): viewtopic.php?f=23&t=6247&p=13230#p13503

this post states that it should be implemented yet : viewtopic.php?t=7577#p17180


Top
   
PostPosted: Tue Dec 18, 2018 8:23 am 
Offline
Frequent User
Frequent User

Joined: Thu Mar 17, 2016 1:24 pm
Posts: 120
Thanks for intention to help, but...

First link it's how to get client IP, not PLC IP. Besides, I know how to get PLC IP, I need to set it.
Second link it's about Ethernet/IP, but I need info how to set settings for common Ethernet adapter (IoDrvEthernet).

In more detail: I see properties IoDrvEthernet.IPAddress and IoDrvEthernet.IPAddressConfigured, but I don't know is it possible to use it for my task and which one I should used (if first answer yes). I also can't test it right now.

I would be to happy hear some comments from Edwin or Marcel, if they find time in this last pre-holiday days.


Top
   
PostPosted: Wed Dec 19, 2018 7:53 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3091
Hi,
sure, you need to enable it in you config file:
example:
/etc/CODESYSControl_User.cfg

[SysSocket]
Adapter.0.Name="eth1"
Adapter.0.EnableSetIpAndMask=1


then in the application:
You could ( for testing purpose) add the ethernet connector and enable the change..
Sure later you do this by iec code.

Code:
        a: INT;
   AdapterInfo : SOCK_ADAPTER_INFORMATION;
   hAdapter: RTS_IEC_HANDLE;
   rResult : RTS_IEC_RESULT;
   udiStructSize : UDINT;
   ERR_OK: UDINT;
   wszAdapter : WSTRING := "br1";
   IP: INADDR;
   Mask: INADDR;
   bSet: BOOL;





Code:
a:=a+1;

// add the following section in "/etc/CODESYSControl_User.cfg"
//[SysSocket]
//Adapter.0.Name="br1"
//Adapter.0.EnableSetIpAndMask=1


(* Test von SysSockGetFirstAdapterInfo/SysSockGetNextAdapterInfo *)
udiStructSize := SIZEOF(AdapterInfo);
hAdapter := SysSockGetFirstAdapterInfo(ADR(AdapterInfo), ADR(udiStructSize), ADR(rResult));
WHILE rResult = ERR_OK DO
   hAdapter := SysSockGetNextAdapterInfo(hAdapter, ADR(AdapterInfo), ADR(udiStructSize), ADR(rResult));
END_WHILE

(* Test von SysSockSetIpAddressAndNetMask *)
IF bSet = TRUE THEN
   bSet := FALSE;
   IP.ulAddr := 16#01010140;
   Mask.ulAddr := 16#0000FFFF;
   
   rResult := SysSockSetIpAddressAndNetMask(wszAdapter, IP, Mask);
END_IF


BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Dec 20, 2018 5:19 am 
Offline
Frequent User
Frequent User

Joined: Thu Mar 17, 2016 1:24 pm
Posts: 120
Thank you, Edwin, and wish a nice holidays. Will try it.
Also vote for CDS-63965 as more simple way. :D


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited