Cannot change default gateway from code

mrbrave
2021-09-01
2021-11-15
  • mrbrave - 2021-09-01

    Hello!

    I am experiencing some problems when trying to change IP-address, subnet mask and default gateway using Codesys standard method "UpdateConfiguredIpSettings". The IP and netmask is updated when the code is executed, but the gateway cannot be changed. I have attached a picture of the running code. And a gif showing displaying the problem.

    Any ideas on what I can try? Am I missing a configuration parameter in the .cfg file or is there any other Linux background setting I need to change?

    • I am using codesys 3.16.3 together with the 4.0.0.0 runtime on a raspberry Pi CM3 based PLC. Network config is done in /etc/network/interfaces.d/*.

    • The options "Adjust operating system settings" is checked under the Ethernet device.

    • I have the following configuration in the CODESYSControl_User.cfg file:
      [SysCom]
      Linux.Devicefile=/dev/ttyUSB

      [CmpBlkDrvCom]
      ;Com.0.Name=MyCom
      ;Com.0.Baudrate=115200
      ;Com.0.Port=3
      ;Com.0.EnableAutoAddressing=1

      [SysProcess]
      Command=AllowAll

      [CmpApp]
      Bootproject.RetainMismatch.Init=1
      Application.1=Application

      [CmpRasPi]
      Architecture=armv7l

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

      [CmpSocketCanDrv]
      ScriptPath=/opt/codesys/scripts/
      ScriptName=rts_set_baud.sh

    BR,
    Simon

     
  • jcarter - 2021-11-10

    I have this exact same issue, I ended up adding in SysSockSetDefaultGateway("eth0",Gateway) after the UpdateConfiguredIPSettings to get around it

     
  • mrbrave - 2021-11-15

    Thanks @jcarter! I will try this aswell.

     

Log in to post a comment.