NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get TS to release USB ownership when unload DLL step

In TS sequence, I call several steps. Each is a CVI DLL, and each talks to several USB devices.
Load Dynamically and Unload after Step Executes is set for each step. For the 2nd and subsequent steps,
XP complains that USB ports are owned by another process, unless I do a USB driver reset, for each port,
at the start of each step. The latter injects a time penalty. If I run each step from CVI w/o TS, XP doesn't complain. Why doesn't TS release the USB port ownership when the prior step DLL is unloaded? Must I perform some post-step
activity or what can be done?
Using TS3.0, CVI 7.0, XP SP1.
0 Kudos
Message 1 of 6
(3,762 Views)
Hi Bob,

Did you really checked that the previous step DLL was unloaded?
Silvius Iancu
0 Kudos
Message 2 of 6
(3,749 Views)
How do I verify that the previous step has been unloaded before proceeding to the next step?
0 Kudos
Message 3 of 6
(3,742 Views)
Can you explain in more detail what you mean when you say that it works when you run each step from CVI without TS. Are you loading unloading or running a project twice in CVI each time, or are you running a CVI project once and in that project you are dynamically loading, running, and unloading the DLLs?
Scott Richardson
https://testeract.com
0 Kudos
Message 4 of 6
(3,737 Views)
I can re-run the step under CVI or run a step, load a new project and the next step, or have two projects loaded in two copies of CVI and run one after the other just fine.
However, though that may work for debugging a step, it doesn't get me where I need to be.
I want to run long sequences of steps under TestStand.
How do I get ownership of the ports released? Is the prior step not unloading, even though I've specified "Unload after Step Executes"? If so, how to I ensure the prior step DLL unloaded before loading the next step? Or do you have another solution?
0 Kudos
Message 5 of 6
(3,733 Views)
Bob -
Assuming that you are using CVI 6.0 or later, when you run a project in CVI it runs the project in an external process. When the debug session completes, the process that controlled the USB is gone. This would be similar to running TestStand with one DLL, closing it down, and doing it again with the 2nd DLL. Since TestStand is running these DLLs in process, I suspect that TestStand is unloading the DLLs, but the driver that you are using to access the USB interface is either not getting unloaded or even if it is unloaded, something about the way it deals with USB is preventing it from freeing the ports. You could see if your DLL is getting unloaded by debugging it and see if the DLLMain receives a detach message.

One issue might be that if a handle to the port is not freed properly it might not release the port and the DLL. You should be able to create a simple test case in a CVI EXE that uses your two DLLs where you open/use/close a USB ports. Do it with one DLL and then the other to see if it works, but do this inside a single CVI EXE, not two separate projects. This would mimic what you are asking TestStand to do.
Scott Richardson
https://testeract.com
0 Kudos
Message 6 of 6
(3,724 Views)