This series of posts covers how you can integrate XJTAG into your overall test system. This entry focuses on executing programs from within XJEase.
The XJEase keyword SYSTEM is used to execute a system command or program. It accepts the command in the form of a string and returns the exit code from the program. This is a 32 bit unsigned value in Windows. It can be used execute any program which contains additional tests and then check for success or failure by examining the return code.
All commands are executed using the Windows Command Processor, cmd.exe. If the Command Processor is unable to start the specified command line for any reason it returns an exit code of 1.
Syntax
SYSTEM( STRING command ) ( INTEGER result );
Example
An example of using this is to perhaps run an external program that measures a frequency. In the example below the “MeasureFrequency” program is assumed to return 0 as its exit code if the frequency is between the two values passed in or non-zero if it falls outside.
INT result; SET TXEN := 1; // Enable transmitter SYSTEM("MeasureFrequency.exe 900000 1100000")(result); SET TXEN := 0; // Disable transmitter IF result > 0 THEN PRINT("Incorrect frequency detected\n"); EXIT; END
By using SYSTEM calls you can therefore run other tests from within XJEase, which can help to integrate all your tests together.
Can it be used to execute batch file?
I’d like to launch a batch file (which load a program via Keil/Ulink2 in the board I’m testing) during the test.
The batch return the ErrorLevel.
The batch file is: Download_Test.bat
It runs from cmd.exe with success.
So I used this function:
SYSTEM(“Download_Test”)(Result);
When I run test programm with XJDeveloper, I get this message:
Download_Test is not recognised as internal or external command…
Someone has an idea?
Hi there,
Yes, you can launch .bat files using the SYSTEM command.
However you do need to call it with the full file extension (.bat) – ie
SYSTEM(“Download_Test.bat”)(result);
Also this will look for a file in the project directory, if it is in another directory you will need to specify that in the system command too…
Bob