Start and Stop a PLC Application using a Command Line Tool

This is the process to start and stop a KAS project from an external device (e.g., an HMI) using HTTP communications.

  • This method uses cURL (http://curl.haxx.se), a command line tool for performing HTTP communication with a server.
  • Two HTTP requests are sent:
    • The first request is to authenticate.
    • The second request starts the application.
curl.exe -X POST -d "username=administrator" -d "password=administrator" -G http://203.0.113.0/authorize/login -c cookie.txt
curl.exe -X PUT http://203.0.113.0/kas/state?newstate=started -b cookie.txt
  • The first request is a POST used to provide credentials to the webserver.
    • The cookie received from the server is stored in a temporary cookie.txt file.
      • This is used in the second request.
    • The username, password, and IP address must be customized for your system.
  • The second request starts the application using a HTTP PUT request.
    • The -b cookie.txt at the end is used to add the authentication cookie received after the first request.
    • The IP address must be customized for your system.

To stop the system, a similar set of commands is used.

curl.exe -X POST -d "username=administrator" -d "password=administrator" -G http://203.0.113.0/authorize/login -c cookie.txt
curl.exe -X PUT http://203.0.113.0/kas/state?newstate=stopped -b cookie.txt

    • cURL exists as a C library.
    • It can be used in compiled software which can be used in the HMI.
    • If cURL is not an option, equivalent tools can be used if they can POST and PUT HTTP requests and support cookies.

See Also