NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Argument for function not viewed able under VC++ by teststand editer

Solved!
Go to solution

Get it through right now, thank you very much.

 

BR.

Bendy

0 Kudos
Message 11 of 25
(3,473 Views)

Erik, I've tried to follow your recommendations for VC++ 6 in my copy of VC++ 2008, but it doesn't seem to work the same way.  Adding the IDL file does not help to expose the parameter names for me.  Using extern "C" seems to break all parameter info for me (no types or names show up in TestStand).

 

From the TestStand 4.1.1 help section titled "Exporting Class Methods and Functions in Visual Studio," it explicity states not to use extern "C" as it will prevent TestStand from obtaining the parameter type info (which I seem to have validated on my machine).

 

Maybe there are differences between VC++ versions and how TestStand interacts with them?

Has anyone successfully created a C++ DLL in VC++ 2008 (or at least .Net) where all parameter information, including names, shows up?

0 Kudos
Message 12 of 25
(3,441 Views)

Eric your solution worked fine!

 

But I still have a question: How can I use a TestStand data type as a parameter (SequenceContext)?

Here is my code: [entry("")]    int    DMM_Konfig    ([out] LPTSTR pResource ,[out] LPTSTR pTarget ,[in] int BufferSize,[in] TS::SequenceContext *seqContext);

 

Cheers Frank

 

 

0 Kudos
Message 13 of 25
(3,435 Views)

Ok I solved my problem, I just had to include the tsapiimportlib.h Now I can see the parameter names in TestStand.

 

But not TS doesn't recognize the data types of seqContext and lpPacked. TS thinks that both are long pointer, see picture.

What do I have to change so that this is working again?

 

 

 

See idl-File Code:

 [
    uuid(FBC87B8C-C738-395A-A08E-0EF3FAB5B544), // UUID doesn't matter to TestStand
]
library TypeLibTest
{
    importlib("stdole32.tlb" );
    importlib("stdole2.tlb" ) ;
    #include "tsapiimportlib.h"

    typedef struct SW_Parameter {
            LPTSTR    lpAction;
            LPTSTR    lpIOChannel;
            LPTSTR    lpSetRes;
    }  SW_Parameter;

    [
        dllname("" ) // name doesn't matter to TestStand
    ]


    module TypeLibTestFunctions
    {

        [entry("" )]        int PSVG_Konfiguration    (LPTSTR pLogicalName ,LPTSTR pResource ,[out] LPTSTR pSpannung ,[out] LPTSTR pStrom ,[out] LPTSTR pOutput,[in] int BufferSize);
        [entry("" )]        int MUSW_Ausfuehrung    ([in] const LPTSTR pStep ,[in] const LPTSTR pResource ,[in] const LPTSTR pOutput);
        [entry("" )]        int    DMM_Konfiguration    ([out] LPTSTR pResource ,[out] LPTSTR pZielVariable ,[in] int BufferSize,[in] SequenceContext* seqContext);
        [entry("" )]        void    StrukturZeug    (SW_Parameter* lpPacked8 , int BufferSize , int* errorOccurred);

    }
}

 

 

0 Kudos
Message 14 of 25
(3,416 Views)

afrankne,

TestStand does not recognize structs and interfaces (including TestStand interfaces like SequenceContext) in type libraries. It converts these types into long pointers. I will write a bug report to address this problem in a future release of TestStand.

 

abradford,

I successfully loaded and converted the VC6 project that I attached to this thread in Visual Studio 2008.You should be able to use that as a starting point.

 

With respect to the use of extern "C" qualifier or a DEF file, let me explain how TestStand gets parameter types from a Visual Studio DLL. If there is a type library associated with the DLL, TestStand uses only that type library to get type information. In this case it doesn't matter if you use extern "C". If there is no type library, then TestStand gets type information from the decorations that the Visual Studio C++ compiler adds to function names that encode type information. In this case using extern "C" removes these decorations and TestStand will not be able to determine the function prototype.

 

Message 15 of 25
(3,406 Views)

Erik, OK.  I think I get it now.  Your most recent post connected the dots for me.

I must have been using extern "C" without the type library generation, and not using extern "C" when using the type library.

I've gotten my code to compile, using extern "C" and a type library in VC++ 2008, and TestStand now sees the parameter names.  Thank you very much! 🙂

 

As for documentation of how to do this, I think it's severly lacking for this aspect of TestStand, or at least not easy to find besides here on the forum.  If for the next version of TestStand there could be a walk though of how to do this, and why each step is important, that would be great.

 

If anyone would like, I can put together a VC++ 2008 solution with a very basic idea of how to do this.  I initially found the VC++ 6 example provided by Erik to not be as straight forward as my present code is, mostly I believe because VC++ 6 added a lot of generated code to his example that got in my way.

 

[edit]: To clarify, I found that using a type library without extern "C" would not load parameter names in VC++ 2008.

Message Edited by abradford on 05-05-2009 09:33 AM
0 Kudos
Message 16 of 25
(3,401 Views)

Thanks Eric!

 

although this is not  what I wanted to read 😉

 

Frank

0 Kudos
Message 17 of 25
(3,397 Views)

On a similar topic, but with strings.

If I compile my C++ DLL with a type library, using extern "C" and a .rc and .idl files, char* or char[] parameters show up in TestStand correctly in the "Description" column, but TestStand expect a number (or an array of numbers).  Passing a string as a parameter gives me a warning about a type conflict.

 

If I compile my C++ DLL without a type library, not using extern "C", my char* or char[] parameters show up in TestStand as "C String Buffer" types and I can pass a string into them.  But then I don't get parameter names.   I kind of want the best of both worlds.

 

Is this similar to what frankne was running into?  Is there any way to use a C++ DLL, with a type library, and pass strings easily?  I can't find much on the topic in the forums on in the TestStand documentation.  I've tried using CNiString, but I don't think it will work with an idl file as it's not a COM type.

0 Kudos
Message 18 of 25
(3,343 Views)
Try using LPSTR for the parameter in the type library instead of char *.
0 Kudos
Message 19 of 25
(3,325 Views)

Erik, that seems to work fine for passing strings into a DLL, but TestStand shows LPSTR as a "const char *" and thus I can't pass a modified string back out of my DLL for something like a string value test.  By not using the typelib, my parameters show up as a char[1024], which is what I want, since then I can pass a modifed string back out to TestStand.

 

I found: http://msdn.microsoft.com/en-us/library/cc230309(PROT.10).aspx and it looks like a good resource for MS types, but I'm not sure what else would work better than LPSTR.  LPSTR isn't supposed to be const char * according to MSDN, whereas LPCSTR would be.

0 Kudos
Message 20 of 25
(3,314 Views)