Command Line Tools
A Command Line Tools app part makes it possible to integrate functionalities (cmd tools) into a system that are usable via the command line and that can be started from a shell without specifying the full path to the tool executable binary.
Necessary additions in the app description file
If the optional JSON object "cmdtools" is present in the app description file, the AppManager knows that at least one command line tool (or an exe file) is inside the app.
The "cmdtools" entry is structured as follows:
"cmdtools":
[
{
"path" : "<path to cmd tool 1 binary>"
},
{
"path" : "<path to cmd tool 2 binary>"
},
{
"path" : "<path to cmd tool [N] binary>"
}
]
"path":
Specifies the path to the executable binary file of the corresponding Command Line Tool within the app container.
Steps to create and integrate Command Line Tool
Create the Command Line Tool:
- Program your Command Line Tool.
- If necessary, license your Command Line Tool.
- Build your Command Line Tool using the PLCnext Technology Software Development Kit.
- Test your Command Line Tool.
Integrate the Command Line Tool to your app:
- The files you are going to need are the binaries of your tool and possibly necessary configuration files. If they are on your PC, it is easiest to copy them with an SFTP client into your app folder on the controller.
- Make sure that your binaries are executable and have the correct access rights, because you cannot change them after installing the read only app container.
- Add the app part "cmdtools" for the cmd tools (“Necessary additions in the app description file”) in your app description file.
Specifications and restrictions
- An app container can optionally contain several Command Line Tools.
- Several Command Line Tools may be active simultaneously in the system.
- The names of the activated Command Line Tools must not occur more than once (neither in an app container nor in all directories of the PATH environment variable).
- Access rights to the tools' executable files must be set in advance (SquashFs read only filesystem).
- The Command Line Tools app part is activated/deactivated when you start/stop the app.
- The activation/deactivation of a Command Line Tools app part does not require a restart of the firmware.
Demo Cmd Tools App
To demonstrate an app with a CmdTool App-Part a simple tool was developed, which is installed in an app and displays a text message on the console when called from the command line.
The C++ source code for the DemoCmdTool:
#include <iostream>
int main(void)
{
std::cout << std::endl;
std::cout << " ##################################" << std::endl;
std::cout << " # #" << std::endl;
std::cout << " # I am a Demo CMD Tool!! #" << std::endl;
std::cout << " # #" << std::endl;
std::cout << " ##################################" << std::endl;
}
The app description for the DemoCmdTool is as follows:
{
"plcnextapp": {
"name": "Demo Cmd Tools App",
"identifier": "00000001111111",
"version": "123.456cmdtool",
"target": "AXC F 2152",
"minfirmware_version": "19.9.0",
"manufacturer": "PhoenixContact",
"licensetype": "Free"
},
"cmdtools":
[
{
"path" : "/bin/DemoCmdTool"
}
]
}
The following sources for the cmd tool demo application are available on GitHub HERE:
- App container folder:
- App description file: app_info.json
- Demo cmd tool binary file (bin/DemoCmdTool)
- Sources folder:
- Source file of the cmd tool: DemoCmdTool.cpp
- Demo app container file: DemoCmdToolsApp.app
After starting the DemoCmdToolApp, the DemoCmdTool can be called from a shell without specifying its full path:
Support in the firmware
The Command Line Tools app part type is supported in the firmware from version 19.3.0.
• Published/reviewed: 2024-11-21 • Revision 17 •