NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Test Stand seq w/ dll batch file execution not working

I am using Test Stand 4.1, running a seq that calls a dll.  The dll contains a batch file execution function that has not been working properly.  I am not 100% sure what the function is as I do not have access to the direct code from which the dll was created.  I believe I have a file, however please remember this is a guess that I am looking at the correct function/file. 

 

This is a Pass/Fail test step that calls a batch file.  The batch file runs properly without the use of Test Stand and called by the dll.  In the code that I believe is running, I see there is a step that I am guessing does not run (see below for test steps).  It seems as though these steps are being "stepped over" and not running, however the test does seem to be entering this function.  The test reports a pass/fail status as the data is reported into a txt file.  If the txt file contains the correct data, the test step reports PASS, even though the batchfile does not run.

 

 

-------------------------------------------------------------------------------------------------

...

 

:Note:  [batchfile.bat] is the name of the batch file being called; the [ ] are not present 

 

// Run Batch File
 ChkErr(LaunchExecutableEx([batchfile.bat] ,windowState,&handle));   
 
 // Wait for batch file to complete task
 do{
  ProcessSystemEvents();
  
 }while(!ExecutableHasTerminated (handle));
 
 RetireExecutableHandle (handle);

... 

 --------------------------------------------------------------------------------------------------------

 

 

Any one have any suggestions as to why the batch file is not being called and running properly?

Thank you

Jason_C

0 Kudos
Message 1 of 6
(4,213 Views)

Jason,

 

I am confused a bit by your explanation.  You say you have a pass/fail step that is calling the batch file directly but it looks like you posed CVI code.  This may be better suited for the CVI discussion forums.  Also, I don't see any "test steps below."  Did you post your sequence?

 

So basically the Pass fail is determined by the step status in TestStand and NOT by what is in your DLL.  Your Step that calls the DLL can change the step status to pass/fail through the parameters by setting the Step.Result.PassFail to a boolean returned by your DLL. 

 

Hope this helps some,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 6
(4,186 Views)

Is the batch file specified by file name, or full absolute path? Does it contain references to other files by file name or full absolute paths?

 

I'm suspecting that your problem might be that the current working directory is different when you run from TestStand. Note that you can create a Windows shortcut to your TestStand UserInterface and in the shortcut, specify the current working directory you want (in the Start In: field).

 

You can use that to quickly see if this is the problem.

0 Kudos
Message 3 of 6
(4,168 Views)

Thanks for the feed back.  I have realized and it seems as though sometimes the CWD varies.  The current working directory when the batch file does not run seems to be set to the desktop, not to the specified directory.  The batch file is used to program a chip, calling the exe to run using commands.  The file are speciifed by an absolute path, however the exe is not.  The batch file is as below and seems to match up with a problem with the CWD.  How can change though?  I will have to check in the Start in field, but where can I find that property? 

 

 

 Thank You

--Jason

 

 

 

-------------------------------------

del ..\misc\mplab.txt

 

echo C:\Program Files\JTRS\01_P55461U\bin\uutsw\CR1_T2V3L_PMM_STUB_LOAD.hex

 

..\misc\pm3cmd /5 /BLCC:\Program Files\JTRS\01_P55461U\misc\t2v3l_pmm_stub_load\t2v3l_pmm_stub_load.pm3 /k /m /y /e >> ..\misc\mplab.txt >> ..\misc\mplab.txt

..\misc\pm3cmd /5 /BVCC:\Program Files\JTRS\01_P55461U\misc\t2v3l_pmm_stub_load\t2v3l_pmm_stub_load.pm3 >> ..\misc\mplab.txt

-------------------------------------

0 Kudos
Message 4 of 6
(4,145 Views)

The test step calls is set to call the dll in an absolute path; C:\Program Files\...\01_P55461U.dll. 

The dll function is selected from the drop down menu.  The function parameters specify local variables defined by the function in the dll for the batch file and txt file (noted in previous post of the batch file contents).  The local variables calling the batch and txt file are also set to absolute paths.

 

C:/Program Files/.../T2V3L_MSP430_PMC_STUB_LOAD_SPARE_ENABLED.bat

C:/Program Files/.../mplab.txt  

 

As seen in the previous post, the only item that is not an absolute path is the "del" and exe calls within the batch file.  When the batch file is called, the following can be viewed in a cmd prompt for the "del ..\misc\mplab.txt" step:

 

C:\Documents and Settings\jcohen\Desktop>del ..\misc\mplab.txt

The system cannot find the file specified.

 

You can see that the mplab.txt file is located in C:\Program Files\... but the cmd prompt cwd is default to my desktop directory.  When looking for the file, it will obviously not be there.

 

Thanks again

0 Kudos
Message 5 of 6
(4,136 Views)

SUCCESS!!  Thanks for the advice. 

 

I figured that I can define the correct location within the batch file since each PC may have a different CWD.  My first line of the batch file is "cd C:\...\bin" to define the correct directory and this solved the problem.

 

Thanks Again

0 Kudos
Message 6 of 6
(4,117 Views)