3

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?

dymanoid
  • 14,771
  • 4
  • 36
  • 64
Harshan.B
  • 93
  • 5
  • 13

2 Answers2

3

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", "");
dymanoid
  • 14,771
  • 4
  • 36
  • 64
0

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.

VioletVynil
  • 502
  • 5
  • 11