Passing a struct from TestStand to LabWindows/CVI

I am passing a struct to a dll written in CVI.
Here is the problem: The code is written in CVI (c code) if I use "struct MyStruct *MyData" as the parameter definition in the dll TestStand works fine. But if I define my struct using a typedef (i.e. typdef struct MyStruct) then use MyStruct *MyData as the parameter TestStand throws a warning. 
I an using the C\C++ adaptor.
It is too late in the programming effort to go back and remove the typedef.
So, how do I get TestStand to accept the typedef?
Thanks
Carmine
Solved!
Go to Solution.

In ANSI C, the struct names and type names belong to separate namespaces. You can declare structs several different ways:
1) struct structName { int x; };
2) typedef struct { int x; } typedefName;
3) typedef struct structName { int x; } typedefName; // Note: structName can be same as typedefName.
I'm assuming you are using the 2nd example above in which case LabWindows/CVI automatically generates a struct name (something like __unknown_1) that Testand uses.
Although you said it is too late to remove the typedef, can you add a struct name as in example 3 above? You can use the same name as the typedefName and TestStand will recognize it.

Similar Messages

  • How can I pass a variable from Test Stand to CVI by reference

    Hi!
    I can't to pass numeric or boolean variable from Test Stand (for example: FileGlobals.StopFlag) into the step (CVI function).
    Function prototype: 
    void __declspec(dllexport) __cdecl PC2_WaitWhileResponceAppear(tTestData *testData, tTestError *testError, int *iStopFlag).
    When variable has bin changed I can't see this change from my function.
    CVI 2010, Test Stand 2010
    Can anybody help me?

    Hey Rombar,
    It is certainly possible to pass variables by reference; for example, if you go to <TestStand Directory>/Examples/Demo/C and open the computer.seq file, you can see one of the example sequences that uses CVI modules. If you click on one of these steps, you'll see that some of the parameters, such as the error information, is passed with pointers. This is a pass by reference.
    To help narrow this down, it'd be good for us to figure out a few things about how the code is run. First, if you go to Configure > Adapters, select the CVI adapter and choose Configure, you can see options for this adapter. Do you have it configured to run in an external instance of CVI or as an in-process call?
    Also, if you're wanting to see a change made in TestStand in your external code, this makes me think that you're wanting to run the code and then continue to execute your TestStand sequence while the code runs. How did you configure this behavior? For example, are you calling this code as a separate sequence in a new thread, or are you using another method to run this code while the sequence continues to run?
    Finally, if we could see a screenshot of how you're configuring the parameters on the TestStand step, that might be helpful as well.
    Daniel E.
    TestStand Product Support Engineer
    National Instruments

  • Pass object reference from TestStand to C#

    Hi,
    I have created a GUI in .NET which i invoke in TestStand (through a custom step type). User can enter a object reference teststand variable in the UI input expression box. So i need to get the object value in that variable and use it to call some .net functions. To get the values from expression box of UI and put in TestStand step variable i use:
             PropertyObject.SetValInterface("Step.TestStationObj", 0, tsexprTestStationObj.DisplayText.Trim()); To check the value in the step variable if i do:
             MessageBox.Show("TestStation obj after setting:",PropertyObject.GetValInterface("Step.TestStationObj",0).ToString());
    But i do not get any value. Guess it is null. Is this a correct way? My intension is to get the value corresponding to a teststand object reference and pass it to C#. The C# UI control is of type NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit

    Thanks Andy.
    I still get the error when i am trying to pass the object created from C# to Teststand. I have explained what i am trying to do. Kindly requesting your assitance on this issue.
    I have 2 classes in C# (code given below), I am trying to pass the object of "Counter" (c1) class from the "Mainfrm" to teststand. In teststand(counter.seq), I am trying to access the function "GetCount() and SetCount()". I have attached the snapshot of the error that i get from teststand.
    Class Counter
        private int count;
        public int GetCount ()
           return (count);
        public void SetCount(int _count)
           count = _count;
    Class Mainfrm : Form
        public Counter c1;
            private void Mainfrm (object sender, EventArgs e)
                InitializeComponent();
                axApplicationMgr1.Start();
                mEngine = axApplicationMgr1.GetEngine();
                currentFile = axApplicationMgr1.OpenSequenceFile(@"Counter.seq");
                pobj = mEngine.NewPropertyObject(NationalInstruments.TestStand.Interop.API.PropertyValueTypes.PropValType_Container, false, "", 0);
                pobj.NewSubProperty("Parameters.ObjRef1", NationalInstruments.TestStand.Interop.API.PropertyValueTypes.PropValType_Reference, false, "", 0);
                pobj.SetValInterface("Parameters.ObjRef1", 0, (object)c1);
                mExecution = mEngine.NewExecution(currentFile, "MainSequence", null, false, 0, pobj, null, null);
    Attachments:
    ErrorFromTestStand.JPG ‏28 KB

  • Find memory leakage when passing Object Reference from Teststand to vi

    I am using Teststand to call labview vi, and pass ThisContext of sequence to vi as object reference, but if I just loop this step and I can find the memory using keep increasing, how can I avoid the memory leakage inside the vi.
    see my vi, it is to post message to UI.
    Solved!
    Go to Solution.

    You should be using a close reference node to close the references you get as a result of an invoke. In the code below you should be closing the references you get from the following:
    AsPropertyObject
    Thread
    Close those two references once you are done with them.
    Also make sure you turned off result collection in your sequence or you will be using up memory continually for the step results.
    Hope this helps,
    -Doug

  • Passing Engine Handle to LabWindows CVI

    Hi All,
    I have run into a situation in test stand where I want to use it in conjunction with a DLL that I have developed in CVI.  In order have them interact properly, I wanted to pass the current TestStand Engine handle into my CVI DLL.  Afterwards, the plan is to use that engine handle along with the tsapicvi activeX control to do what I need to do.
    However, I cannot seem to get this working correctly, as I keep getting an invalid handle error from my CVI activeX controls with the handle I have passed into it from teststand.  Here is what I have so far.
    In TestStand Sequence A calls the CVI DLL:
    Sequence A has a single parameter called Engine.
    Parameter Engine has the teststand Category TSObject with type TS::IEngine passed By Value.
    The value passed into the parameter Engine is RunState.Engine
    The CVI DLL has a single function GetHandle
    GetHandle has a single parameter which is TSObj_Engine *ts_engine.
    This function calls TS_EngineGetLicenseDescription (*ts_engine, NULL, 0, &desc); (just a random function that I use to test it).
    Any suggestions on where I might have gone wrong with this?
    CVI 7.0
    TestStand 3.1

    Hi Ray,
    Thanks for the quick response! 
    To answer your question, yes, I do set the Engine parameter in TestStand to RunState.Engine.
     However, all I know about the TS:IEngine containter is that it has one (or more) data fields that get passed to my DLL.  I don't know what those fields are, so on the DLL end I am not sure what I should be getting.  i.e. the function prototype in my DLL should probably contain some struct, but I don't know what the struct is.  The only guess I can make is that teststand is passing me a TS_IID_Engine type struct (defined in tsapicvi.h).  However there are 4 data fields in this struct convienently labeled Data1 - Data4, all of which i tried using as a handle, and none of which worked.

  • How can I pass arguments to a TestStand sequence with LabWindows 6 ?

    Hi
    I have created sequences in a TestStand file.
    I want to program a sequence with Labwindows 6 which would call all these existing sequences (containing parameters).
    I don't have any problems to create the steps "SequenceCall" but i don't know how to pass arguments to the sequences with the TS API.
    I have used the look-up strings "TS.SData.SFPath", "TS.SData.SeqName", "TS.SData.ThreadOpt" to program the sequence file / sequence and the multithread option. But now how to program the arguments passing ? I think there is something with the lookup string "ST.SData.ActualArgs"...
    Thank u very much for any help

    I'm not sure if you want to pass values from TestStand to LabWindows or if you want to pass values in TestStand from a sequence call step to a called sequence.
    To get TestStand variables from LabWIndows, use the following function:
    tsErrChk (TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, "Locals.StartPoint", 0, &dStartPt));
    iStartPt = (int)dStartPt;
    The TS_PropertyGetValNumber gets the TestStand variable Locals.StartPoint and puts it into the LabWindows variable called dStartPoint. Numbers to and from Test Stand are always a double type. The next line converts it to an integer.
    To put a LabWindows value to TestStand, use TS_PropertyPutValNumber.
    To pass values from a sequence call step to a called sequence, create variables in the Parameters t
    ab on your main sequence. Create same variables on the Parameters tab of the called sequence. In main, specify module to be called in calling step. There is a paramters section on the Edit Sequence Call dialog box which appears. Check the Use Prototype of the Selected Sequence box. You can then list all the parameter variables in the parameters section.
    Hope this is what you want.
    - tbob
    Inventor of the WORM Global

  • Can I convert Labview panel to Labwindows/CVI uir file

    I a project that I want to convert from labview to Labwindows\CVI.
    I don't want to call my VI's from LabWindows.
    It is possible to convert some Labview fronts panels to *.uir files (Labwindows/CVI)
    Thanks

    Hi Artus!
    Unfortunately there is no automatic way to convert a LabView Front Panel into a Labwindows UIR.
    The only way you can do this is by creating a new interface and adding all the elements that you need, but this way would actually mean rebuilding everything based on something you already have. Sorry about the bad news
    I wish you the best day!
    Oswald Branford

  • Passing variables into CVI from TestStand.

    Is there a different way to send variables into CVI from TestStand other than the input buffer? Parsing that string is annoying and bulky. Isn't there an easier way?

    Hi,
    Here is a short cut to another example which will use the StationGlobals -
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=313&HOID=506500000008000000301F0000&UCATEGORY_0=_8_&UCATEGORY_S=0
    There are loads of other examples either as part of the examples provided by TestStand installation or in the Resource Library under TestStand on the NI website
    Good Luck
    Ray Farmer
    Regards
    Ray Farmer

  • Passing SAFEARRAY Pointer from CVI

    Hi,
    I am having problem in importing IVI-COM dll to C wrapper dll in Labwindows/CVI. I have to do that for my TestStand application to call the functions of the dll. After registering the COM dll, I have used �Create Activex Controller� option to create .c, .fp and .h files. With this, I was able to create dll but without any prototype info. So, I included the fp file to include prototype info. But while I create my dll with the type lib info, odl file gave error to use SAFEARRAY pointer. So I have declared a structure mySAFEARRAY (same parameters as that of SAFEARRAY) and has replaced all the (SAFEARRAY *) to (mySAFEARRAY *). After doing this, I have created the dll successfully.
    Now in TestStand when I have called the dl
    l with �Flexible Prototype Adapter�, few of the data types (structures) are not applicable to TestStand. So it is taking all the unknown data types to �long�. When I check the prototype with my C file, it is telling mismatch prototype.
    Now, please help me what do we do for the C wrapper dll to work proper. Is the procedure (which I have described above) proper?
    I have got one info from NI site, that the functions using the structure parameters should not be exported directly. Instead a wrapper function should be created, with each and every element of the structure as it parameter. Now do we create a wrapper function for each and every function which has the structure parameter in it? I am eagerly waiting for your information. Actually i am new to both CVI and TestStand.
    Thank you in advance for your help.
    Thank you,
    Sasi.

    Hello Sasi -
    I am uncertain what your situation is, but it sounds like you are trying to pass the SafeArray as a parameter of your DLL back to TestStand? TestStand only recognizes certain known types when it comes to creating new memory to hold variables. A SafeArray is fundamentally an array of objects, so passing it directly to TestStand is unlikely to work. Your best bet is to look into the LabWindows/CVI examples and functions for converting SafeArrays to one-dimensional arrays of numbers, and passing that array back to TestStand via a parameter or some API call.
    As an additional note, there are generic examples of how to successfully pass structures back and forth between TestStand and code modules, but it requires both environments having a definition o
    f the structure as well as agreeing upon the byte-packing of the data. The best resource I can provide is to point you to the TestStand shipping example located in the /Examples/Struct Passing/ directory. However depending on how you are attempting to extract that SafeArray, this may not be an issue (as far as writing a numeric array vs. writing a structure).
    If this doesn't help answer your question, maybe you can give me a little more information, maybe a function declaration for your code, to try and see what you are doing in more detail?
    --Regards
    Elaine R.
    National Instruments
    http://www.ni.com/ask

  • How to access the result list in teststand after execution using labwindows​/cvi

    I am developing a user interface in labwindows/cvi that runs multiple teststand sequence files and would like to combine their reports (generated in teststand) into a single file at the end of a UUT. What is the best way to do this? At the moment, I'm trying to access the result list local variable after the execution has ended using API calls from labwindows/cvi and an end-of-execution callback event but those run-time variables do not exist anymore. How do I get a hold of the result list array at the end of an execution? I would like to grab this variable and pass it along from sequence to sequence using labwindows/cvi and not teststand itself. Is this possible? Any help would be great.
    Thanks in advance,
    Luis

    Hey Luis,
    Check out the response to this thread at the NI TestStand board here!

  • Import c struct from dll header file into TestStand?

    Hi,
    I'm writing a TestStand sequence to call some CVI functions I have compiled into a dll. One header file in the CVI code is the interface to the dll and declares some functions and some C structs which are to be passed into the functions as pointers. These structs are populated with test results as the CVI code executes. I want to import these structs into TestStand.
    TestStand seems to have properly imported my function calls because I can select them from a drop-down list. But it doesn't seem to recognize my struct definitions, because it just says "unknown __struct 617*" -- it knows it's a C struct pointer but doesn't know what fields exist in the struct.
    How do I get TestStand to recognize the fields that are in my structs?
    The C functions and structs are declared with DLLEXPORT in the header file. I compile the CVI code into a dll, with the target settings set to export marked header files and symbols. The only header file marked in the target settings dialog is the header file declaring these functions and structs. So I think they're being exported properly into the dll.
    Any ideas to help?
    Thanks!

    I'm using typedef struct {...} MyStruct; to make life easier in CVI world, so rather than changing that throughout my CVI code I think I'll just live with the fact that TestStand doesn't know what struct type it is.
    But typedef or not, is it ever possible for TestStand to import the struct definitions (ie so that it knows what fields and types exist within the struct)? Or do I have to make containers in TestStand that match the format of the structs I'm using in CVI, and pass those container pointers into my CVI function calls?
    Thanks!

  • How can I pass a Variant to a C++ DLL from TestStand?

    I have a VARIANT that is being returned to TestStand via COM. The variant contains a structure of integers and strings. The integers are not uniformly sized... some are 8,16, and 32 bit. Rather than try to find a way to decode this information in TestStand, I would like to pass it to a C++ DLL to do the decoding and return the information in a readily usable format. I also have need to take the aforementioned data types, send them to a DLL for conversion into a VARIANT, and then pass this variant to a COM object. Can someone please explain a way that I can use TestStand as a pass-through for VARIANTs between a COM object and a C++ DLL?

    Hi,
    To pass a VARIANT to a C++ DLL in TestStand, you will need to create a custom data type.  From the sequence, change the View ring to Sequence File Types.  Right-click to insert a new Customer Data Type and select Container.  Now you can right-click to insert a field, which you can specify what data type it is.  Insert as many fields as needed.  After you have entered those in, right-click on the Custom Data Type name and select Properties.  Go to the C Struct Passing tab and click the "Allow Objects of this Type to be Passed as Structs".  Change packing to correlate with the C++ compiler you are using and also configure the properties for each field.
    Once you have done this, you will be able to pass that VARIANT as a struct to a C++ DLL.
    Thanks,
    Terry S.
    Staff Software Engineer
    National Instruments

  • Retour paramètre string par Labwindows/CVI pour Teststand

    Bonjour à tous,
    j'utilise Teststand 2012 Development System et Labwindows/CVI 2012 Development System sous Windows 7 professionnel.
    Le contexte : grâce à une DLL crée avec Labwindows/CVI j'appel la fonction "Traitement" par TS.
    Le prototype de la fonction est le suivant void __declspec(dllexport) Traitement (char message[256], car reponse[256]);
    Je passe en paramètre deux strings à cette fonction. Cette fonction reçoit un "message", effectue un traitement sur celui-ci et le renvois sous le tableau "reponse" à TS. Cette fonction a été testée et fonctionne sous CVI.
    Mon problème : J'ai vérifié ma fonction reçoit bien le message mais me retourne quelque chose d'erroné( cf. image) et n'est censé me retourner, dans"reponse", que les chiffres au début mais me rajoute des instructions en temps que string. Je ne comprend pas comment cette suite d'instruction ce rajoute et pourquoi?
    J'ai consulté tous les messages disponibles sur le forum et je n'ai pas réussi à trouver un problème équivalent et donc une solution.
    J'espère que vous aurez une idée, voir pourquoi pas une solution
    Dans l'attente d'une réponse,
    Cordialement,
    Erwan.
    Résolu !
    Accéder à la solution.
    Pièces jointes :
    message.png ‏74 KB

    Bonjour Akagi,
    Dans une chaîne de caractère, "Null" ou "\0", correspond effectivement à une fin de chaîne.
    Pour éviter ce comportement, vous pouvez changer le type de passage de paramètre dans TS en tableau de Numérique.
    Ce faisant, aucun traitement ne sera fait sur le caractère "NULL". pour rappel un char = 1 Octet, on peut donc utiliser un tableau de numérique U8 pour représenter une chaîne de caractère.
    En résumé, si votre chaîne de caractère = 3"Null"01, vous obtiendrez ainsi: tab[0] = 3, tab[1] = 0, tab[2]=1.
    Je suis désolé, mais j'ai du mal à saisir où est intégré le caractère "NULL" dans CVI, est-ce une entrée clavier saisie par l'utilisateur, autre?
    Est-il possible d'utiliser un autre caractère ou série de caractère(non spécial) permettant d'identifier cette transition/caractère spécial "Null"?
    EX: (\) = "Null", soit la chaîne 3(\)01 équivalent à 3"Null"01. Il suffit ensuite d'établir un algorithme permettant de changer (\) en "NULL".
    Cordialement,
    Rémi D.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Les rencontres techniques de NI - Mesures et acquisition de données : de la théorie à la mise en ...

  • Passing and Receiving Struct from Test Stand

    Hi All,
    I have this DLL with this function:
    long __declspec(dllexport) InitMyNodeID(char* nameNode myData* mh)
     GimmeMyNodeID(nameNode, &mh->myNodeID);
    struct myData {
    int myNodeID;
     Notes:
     GimmeMyNodeID is a standard API that receives nameNode as input and returns an int myNodeID.
    I'm having difficulty receiving it on the test stand parameter...
    Can somebody help me on this..)

    Ray,
    in order to pass structs as parameters from/to TestStand, you have to define a datatype. In the typedefinition, you can set a property which is called "Allow Objects of This Type to be passed as Structs".
    Then you have to create a variable using this type and there you go
    hope this helps,
    Norbert 
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Update Station Globals from LAbWindows/CVI user interface

    Hi,
    I am having a requirement such that i need to update a station global variable to true or false based on the click on a button present in User Interface.
    My Setup:
    Labwindows/CVI 8.5
    TestStand 4.2.1
    Please advice me.
    Solved!
    Go to Solution.

    Hi,
    first thing, why have you posted this query twice, http://forums.ni.com/t5/NI-TestStand/Update-Station-Globals-from-CVI-UI/m-p/1317023
    to be able to update a StationGlobal, you first need to get a reference to the Engine, this can be done using ApplicationMgr.GetEngine()
    Once you have that reference you can then get a reference to the StationGlobals by the use of Engine.Globals(). this returns a PropertyObject.
    So now you can use the SetVal methods to set your boolean, eg PropertyObject.SetValBoolean("MyBoolean",  0,  True)
    hope this helps
    Regards
    Ray Farmer

Maybe you are looking for

  • Summary PO Report Query

    Hello All -- We currently have this Query below that shows Open PO's in detail.  We would like a summary form of this -- so instead of showing every single item being received in the PO, it just shows total qty and the style #.  Out item code is 9 di

  • Browser wont open!

    I just bought a bbz10 cause it seemed like a cool phone. I fell in love with it since the day i got it untill last night when i clicked the browser app and it didnt open, the brower app icon just blinked but it didnt launch. same with youtube and wea

  • Ipod touch and new computer!

    I had installed itunes on my old computer, the hard drive failed and I had to insall a new hard drive, having done so when I plug in my Ipod touch it indicates that I have to resync my ipod to the new machine, but this will mean I lose all my music.

  • Configurable material sales order costing after delivery is created

    Hi, Sales order was re-costed after delivery and goods issued. The costing is VO - without errors. The profitability analysis does not show cost for the sales order line and there is no offset g/l account . Please see attached. Appreciate it.

  • HD import footage out of sync in Final Cut Pro X.

    I am finally using my Final Cut Pro X and just got a Canon Vixia HF G10. I imported my first footage just a quick sample - only 25 seconds. The audio is not in sync with picture. In iMovie HD it plays perfectly but I need to use Final Cut Pro X. This