01-05-2011 09:04 AM
All,
I have developed a DLL that control's a USB based power supply. The dll call works from TestStand 4.1 most of the time. What I believe is happening is that each time I call the dll in my Main sequence file AS WELL AS other sequence files, that multiple instances of the dll are loaded.
Part of the init of the power supply is to pass back a SESSION number, which is used in subsequent calls to the dll. I store it as a Global variable in TestStand and pass it around to what ever sequence needs it.
How can I load the DLL at the start of the sequence and PASS a reference (Handle) to all additional calls to the dll?
thanks in advance
Carmine
Solved! Go to Solution.
01-06-2011 09:45 AM - edited 01-06-2011 09:47 AM
Only one copy of your dll should ever get loaded at a time. This is how the Windows OS works. The only way to have more than one copy loaded is if there is more than one copy on disk (If that is the case, you can fix it by only having one copy on disk and having all sequences reference the same copy). Also, what might be happening is that you might be unloading the dll after each call. Make sure the unload and load options for your steps which use the dll are configured to keep it loaded for the length of time you desire.
Hope this helps,
-Doug
01-06-2011 12:06 PM
I checked and found that I had a release and debug version that were both beig called. That is now corrected. (Thanks)
Program still has the problem.
The "proper dll" is called from my first sequence, but called again in other sequences that are in separate files. As you suggested I looked at the load and unload options> I am not seeing an option that keeps the dll from unloading when the sub sequence file finishes and exits.
Program Architecture is as follows:
"Main File.seq" calls a "Child1.seq" to init a power supply and passes back a HANDLE, Now "Main File.seq" AND "Child2.seq" make calls to the Power Supply using the HANDLE.
Any additional help is welcome.
Thanks in advance
01-06-2011 03:12 PM
If your sequence call steps and dll steps are all set to "Unload when sequence file is unloaded" then your dll should stay loaded until the execution completes and your execution window is closed, unless you are calling the Engine.UnloadAllModules() API somewhere. You can also make sure the dll stays loaded for at least the lifetime of the mainsequence by adding a call to it in there, but that shouldn't really be necessary unless you are calling Engine.UnloadAllModules() somewhere. Have you verified for sure that your dll is getting unloaded? Is it possible there is a different cause for the issue you are seeing?
Hope this helps,
-Doug
01-06-2011 03:39 PM
I do call for a Engine.UnloadAllModules() but only in the first seq file (the Main one) and only in the cleanup section, but will recheck it.
But I will try moving the original callto the dll in the Main Seq instead of the child seq and will advise.
Thanks
01-07-2011 09:38 AM
Just want to clarify that calling UnloadAllModules() will unload modules no matter what the setting is on the steps, so make sure you aren't calling it until you really want the dll to get unloaded.
Hope this helps,
-Doug
01-07-2011 12:23 PM
Doug,
Thanks for your help. I found an UnLoadModules() in one of the child seq that I missed. Unless I missed any others, I believe this should be resolved.
Carmine