From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Detaching DLL closes network connections

I'm using TestStand to call a sequence (DeveiceConfig.seq) that calls a step that loads a DLL that contains a function for opening a network connection to a test instrument. I call DeveiceConfig.seq via a customzation of the Tools menu. The problem is that once DeveiceConfig.seq is executed it is unloaded which causes the DLL I used to do the connect to be "DETACHED" resulting in this DLL closing the network connection to my instrument. I use this connection in other sequences I have loaded in TestStand.
Anyhow, the behavior I would like is for the connection to be closed when I exit TS, which is the behavior of my GPIB connections. I realize I can force DeviceConfig.seq to be loaded when the user loads a sequence (e.g., TestSeq.seq) that will need this network connection by having DeviceConfig.seq called in the Setup sequence of TestSeq.seq. But, I don't want it to run each time TestSeq.seq is executed since the device configuration for a particular station should be pretty stable (certatinly it won't change between TestSeq.seq runs). Any thoughts?
0 Kudos
Message 1 of 3
(2,616 Views)
Hello,

Depending on the behavior that you are expecting there are a couple of different options that you could try. First, if you are using this sequence as a subsequence, I would recommend calling it in a new thread. This sequence which is being called in a new thread could open the connection to your instruments. It could then remain running while your other sequences are performing there operations. You could then stop this sequence which is running in a new thread when your testing is finished. If you are interested in running different sequences by hand, but still want the connection to be open, I would recommend calling the sequence which opens your instrument connection in a new TestStand execution. I hope that this information is helpful.

Regards,
Kevin L.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(2,603 Views)
To MrPonny -
A Tool menu performs the following actions:
Opens the sequence file
Runs the sequence in a new hidden execution
Releases the execution
Releases the sequence file

Because the unload options say to "Unload when Sequence File is Closed" the engine releases its LoadLibrary handle to the DLL for the step that you are interested in. You need to find a way to unsure that the DLL stays loaded in memory after the sequence file is unloaded.

The simplest way would be to add a reference to the DLL by calling "LoadLibrary" on the DLL and let the DLL be "unloaded" when the process exits. If you wanted more control over the DLL, you could store the handle returned by LoadLibrary in a numeric variable that you create on the container property object return from Engine.TemporaryGlobals. This way you could have a tool menu or some other way to call FreeLibrary using the handle at a designated time.
Scott Richardson
0 Kudos
Message 3 of 3
(2,574 Views)