I would like to run an executable from a CAPL script. Is there any function for that?
I am looking for a function which will run an executable in the background. E.g. if a certain message is received, then start an application.
Is there any possibility in CAPL for that?
Yes, there are two functions to do that:
long sysExec(char cmd[], char params[]);
long sysExec(char cmd[], char params[], char directory[]);
long sysExecCmd(char cmd[], char params[]);
long sysExecCmd(char cmd[], char params[], char directory[]);
These functions execute an external command. They do not wait until the command has completed its execution. The return value is 1 if the command was successfully started; otherwise, 0. Note that no return value from the command itself will be returned because the call does not wait for the command to finish.
sysExec must be given an executable; sysExecCmd calls cmd.exe /K with the first parameter, which opens a command window where the command is executed as if it was entered directly.
Note that in case of a distributed simulation environment using a VN8900 device, a real-time module (VT 6000 family) or a CANoe RT server, sysExec executes the requested command on the remote platform.
Here is an example:
sysExec("C:\\windows\\notepad.exe", "");
The 3rd option, if you don't need the parallel processing is the testwaitforsyscall() function.
This will wait x timeout to your external executable to return, and will analyze if your application exit correctly, incorrectly, with errors, or timed out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With