How to stop dhcpcd and use SysSockSetIpAddressAndNetMask to set address?

DavidBo
7 hours ago
4 hours ago
  • DavidBo - 7 hours ago

    It is stated:
    "Dynamic ip address, provided by DHCP, BOOTP, etc. Cannot be changed by SysSockSetIpAddressAndNetMask()"
    Therefore I try to stop dhcpcd and flush the eth0 like this

    VAR CONSTANT
        flushIP:STRING:='sudo ip addr flush dev eth0';
        stopDHCP:STRING:='sudo systemctl stop dhcpcd';
    END_VAR
    
    SysProcessExecuteCommand2(pszCommand:=stopDHCP, pszStdOut:=stdout,udiStdOutLen:= SIZEOF(stdout),pResult := ADR(Result));
    SysProcessExecuteCommand2(pszCommand:=flushIP, pszStdOut:=stdout,udiStdOutLen:= SIZEOF(stdout),pResult := ADR(Result));
    

    Besides losing the connection when flush occurs the CODESYS halts, seen on the display and I cannot see why, because I have lost the connection from my IDE.
    Why does the flush command halt the execution of the application?

     
  • DavidBo - 4 hours ago

    The reason for why CODESYS halts was a CODESYS watchdog exception. 'sudo ip' takes a long time.

     

Log in to post a comment.