Hello everyone, I am trying to change dynamically by code the IP address of a Weidmuller controller. So I am basically using IoDrvEthernet library to use UpdateConfiguredIPSettings function but I am getting constantly the 'INVALID_STATE' error.
Even though I am following a procedure it should work:
* First I added on the config file of codesys the following: [SysSocket]
Adapter.0.Name="eth0"
Adapter.0.EnableSetIpAndMask=1
Adapter.1.Name="eth1"
Adapter.1.EnableSetIpAndMask=1
* Secondly I am first disabling the ethernet interface by using Ethernet_0.Enable = FALSE and then executing DED.Reconfigure. After that, I run the Ethernet_1.updateConfiguredIPSettings
IF Reconfigure.xDone OR Reconfigure.xError THEN
Reconfigure(xExecute:= FALSE);
END_IF
Can someone help me? Thank you. All I am trying is to find a way to change dynamically with code, the IP addresses of my controller (2 ethernet ports).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone, I am trying to change dynamically by code the IP address of a Weidmuller controller. So I am basically using IoDrvEthernet library to use UpdateConfiguredIPSettings function but I am getting constantly the 'INVALID_STATE' error.
Even though I am following a procedure it should work:
* First I added on the config file of codesys the following:
[SysSocket]
Adapter.0.Name="eth0"
Adapter.0.EnableSetIpAndMask=1
Adapter.1.Name="eth1"
Adapter.1.EnableSetIpAndMask=1
* Secondly I am first disabling the ethernet interface by using Ethernet_0.Enable = FALSE and then executing DED.Reconfigure. After that, I run the Ethernet_1.updateConfiguredIPSettings
Code:
Ethernet_1.Enable:= EnableDisable;
Reconfigure(xExecute:= TRUE,
itfNode:= Ethernet_1,
xError=> ErrorReconfigure,
eError=> ErrorCodeReconfigure);
IF Reconfigure.xDone THEN
ErrorCodeIP:= Ethernet_1.UpdateConfiguredIPSettings(IPAddress:= newIP,
SubnetMask:= newMask,
Gateway:= newGW);
END_IF
IF Reconfigure.xDone OR Reconfigure.xError THEN
Reconfigure(xExecute:= FALSE);
END_IF
Ethernet_1.Enable:= TRUE;
Reconfigure(xExecute:= TRUE, itfNode:= Ethernet_1);
IF Reconfigure.xDone OR Reconfigure.xError THEN
Reconfigure(xExecute:= FALSE);
END_IF
Can someone help me? Thank you. All I am trying is to find a way to change dynamically with code, the IP addresses of my controller (2 ethernet ports).
check the plclog for the error on doing this
I did check I cannot see any error log. It is when executing the Reconfigure function that I get an error as return from that function.