NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET code module not executed using Substeps

I am facing an interesting problem, that I would guess, can be easily explained with compatibility issues.

 

We are using TS 2021 SP1 and have a DLL which describes communication with our particular device. I am configuring custom step types for common functions of the device and can use it with a direct call.

 

But the problem occurs when I try to use it within the step's Substeps. For example, I need to open a COM port, receive the handle object, use it for communication and then close/release it. For whatever reason, even though I see an object being created, it is unable to communicate with the device. 

 

If I move the function to general adapter's code module it works... Is this simply a compatibility issue? DLL is in .NET 4.7.2

luklem_0-1739374589283.png

luklem_2-1739374622881.png

Settings are identical

 

0 Kudos
Message 1 of 6
(241 Views)

Where are you storing the handle?

0 Kudos
Message 2 of 6
(235 Views)

Originally, idea of the framework was to have it in StationGlobals. For debugging purposes, we tried to store it everywhere, locals, fileglobals,stationglobals.

0 Kudos
Message 3 of 6
(203 Views)

Not directly related to the issue you are seeing...

From what I understood from the initial post, the StepType is supposed to open the COM, so the CodeModule can do stuff with it. After the execution of the CodeModule the COM is closed.

If that is the case, IMHO the COM handle should bet stored somewhere in the Step data structure, since it is associated to the particular step only.

Focussing on the current issue... In the StepType definition, you are only having that single PreStep, right?


 

0 Kudos
Message 4 of 6
(195 Views)

To your first topic - yes and no, later down the road we will have functionality like this, so that one step would have multiple functions (e.g. Open, Read, Write, Close), but currently it should only OPEN the port and store the handle in variable.

 

And the current issue - yes, we have only 1 PreStep, which should Open the port.

 

I should add, that if I open the Port from the Pre-Step, I can not even close it using the returned handle, I have to re-plug the device in order to get the COM working again.

0 Kudos
Message 5 of 6
(187 Views)

@luklem wrote:

 

 

I should add, that if I open the Port from the Pre-Step, I can not even close it using the returned handle, I have to re-plug the device in order to get the COM working again.


Can you try "Unload Code Modules" instead of unplugging the device?

 

0 Kudos
Message 6 of 6
(183 Views)