05-30-2013 05:02 PM - edited 05-30-2013 05:03 PM
I need to add a new feature / function to an existing TestStand program. The original program uses a custom data type for the LabVIEW VISA (serial com) reference, as shown below. I want to use the StationGlobals.VISA_Ref in my call to the dll.
The VI prototype is shown below. The VISA Ref In is a basic VISA reference control (serial comm) from LabVIEW. Nothing special.
I am stuck at trying to figure out how to configure the VISA Ref In parameter... I've searched this forum and the only posts which seem close to what I am attempting to do did not have any responses... I hope to be "luckier".. 😉
05-30-2013 07:17 PM
Hi Ray,
One way to do this is to create a struct in your source for the DLL that matches the LabVIEWIOControl. Then set the VISARefIn input parameter to be this struct type. Note as this standard data type does not currently have the C Struct Passing option enabled (TestStand v4.2.1) to allow this objects of this type to be passed as structs, you'll need to edit this - see the C Struct Passing tab on the LabVIEWIOControl type Properties. From the help:
You can use the C/C++ DLL Adapter or LabWindows/CVI Adapter to pass a TestStand variable or property to a structure parameter in a code module function. The data type of the variable or property you pass must contain all fields the structure parameter expects. If a data type contains a subproperty that is a named data type, you must also allow objects of the named data type to be passed as a structure.
There are several ways to format data type fields in the in-memory representation of a structure parameter. Use the C Struct Passing tab to specify how TestStand formats an instance of a data type you pass as a structure in memory.
The C Struct Passing tab can contain the following options:
...
Another (and much simpler method IMO) is to change the inputs to this function to take the two container values are seperate inputs of type string and numeric respectively.
Let us know if this doesn't help.
-Jack
05-30-2013 08:15 PM - edited 05-30-2013 08:17 PM
What you are describing is similar to this, right? http://digital.ni.com/public.nsf/allkb/22BF02003B4588808625717F003ECD67
I tried something similar to what you described.... unfortunately, TestStand is holding on to the serial port and has not let go yet... Which causes a run-time error within the LabVIEW code (dll) because the resource it is trying to use (COM port) is not available... 😞
I will check the code and see whether they use the serial port after it gets to the new feature... Otherwise, I may close the port, use it within LabVIEW (dll), close it and then re-open within TestStand... That's why I wanted to pass the reference directly... Although, the way you describe it, it may be possible to pass that same reference indirectly and get the dll to work without having to play with closing / opening references. I'll explore that tomorrow.
Thanks.
🙂
05-31-2013 04:16 PM
Hi Ray,
Fundamentally, yes they are similar. If I understand you correctly, then you should be able to pass an existing handle reference to your new DLL call, and it should be able to use it, and that shouldn't have anything to do with you being able to pass this as a structure.
Hopefully you have it working by now... Let us know if not.