Trouble accessing a struct returned a DLL function

I realize, this is a recurring theme on the forums, but I've not been able to find a thread that has successfully helped me to solve my problem, here's so I write.

I work with a third party dll to get x, y data z to a device. I'm having problems when you try to use the following C function (via call library node):

int ArmGetTipPosition (length_3D * position);

where:

typedef float length;

Is it possible that your DLL is really a full group of 0?  Maybe you need to call another function in the DLL first to get something initialized?  If the cluster that you place in the node library call contains values non-null, this does affect the output?

Tags: NI Software

Similar Questions

  • How to handle a function with struct return of dll?

    I have a dll 'SCTSCTL_OPEN' function returns a structure like

    typedef struct _sctsctl_t {}
    HANDLE hDevice;
    unsigned char ctl [2];
    unsigned long necessarily;
    unsigned long data_diff;
    HANDLE IsrThread;
    HANDLE IsrEventHandle;
    PVOID can't;
    void (* Manager) (struct _sctsctl_t * board, int intvec);
    } * sctsctl_t;

    SCTS_API sctsctl_t __stdcall SCTSCTL_OPEN (DWORD instance);

    I have imported this dll with LabVIEW and vi returns an unsigned long integer shown as follows.

    How to make a comeback with structure? Any help would be appreicated.

    Kind regards

    Adam

    LV 8.5.1

    Normally I would be tempted to do a wrapper function and call it with LV LV. handles structure not so naturally.

  • Call the function in LabView from a DLL, and then access the global variable of DLL

    I've created a DLL in LabWindows with a function and structure.  I want to call the function from LabView and then access the overall structure.  I am able to call the function in the DLL with a "call library function node" and has access to the return value, but I can't understand how to access the overall structure.  The structure is declared in the header DLL with __declspec (dllimport) struct parameters file.

    Is it possible to access this structure without using the library of network variables?

    My guess is that you need two bytes of padding after "in_out" and another to two bytes of padding after "anin."  The reason being that ints are 4 bytes, and most of them C compilers will align on 4-byte boundaries.  The struct will naturally start to such a limit (in fact, in Windows, it will probably start to an 8 byte boundary).  If you then count bytes in your structure, you are 70 byte after "in_out."  70 is not divisible by 4, so you need 2 bytes more to reach the next 4 byte boundary.  You can also you could reorganize your struct so that "anin" follows "in_out" and this is probably the best option if it won't cause you other problems.

    Unlike most C compilers, LabVIEW compressed structures as closely as possible, without filling.  I don't know enough about the history of LabVIEW and internal parts to explain the reasons and to do this performance penalty, but, as choice of LabVIEW "endianness", it is probably a remnant of the first versions of LabVIEW that were running on the Mac.

    If for some reason you want to force your C struct to match package LabVIEW, you can use the #pragma pack (x) directive, but I wouldn't recommend that here because you can control the C and LabVIEW.

    EDIT: in the cases where it was not clear, add padding to your cluster of LabVIEW, insert appropriate size or items at the place desired in the cluster.

  • Call the DLL function with a pointer to a complex structure

    Hello

    I try to call a function by using COLD LAKE. My problem is the function parameters that I'm trying to access.

    Here is the function and its parameters:

    typedef struct _BAR_INFO
    {
    ULONG dwSize;
    ULONG dwFlag.
    } BAR_INFO, PBAR_INFO;

    typedef struct _DEVICE_INFO
    {
    ULONG dwBarNum;
    BAR_INFO BarInfo [6];
    } DEVICE_INFO, * PDEVICE_INFO;

    Int GetDeviceInfo DLLIMPORT)
    unsigned int CIH.
    PDEVICE_INFO pdevinfo
    )
    {
    ULONG i;

    If (DFR > = DevNum)
    Return PCICORE_DEVICE_NO_FOUND;

    If (DevTable [JC]. DevHandle is NOTHING)
    Return PCICORE_DEVICE_NO_INITIALIZE;

    if(pdevinfo == null)
    Return PCICORE_INVALID_PARAMETER;

    pdevinfo-> dwBarNum = DevTable [JC]. DevInfo.dwBarNum;
    < pdevinfo-="">dwBarNum; i ++)
    {
    pdevinfo-> .dwFlag BarInfo [i] =
    DevTable [JC]. DevInfo.BarInfo [i] .dwFlag;
    pdevinfo-> .dwSize BarInfo [i] =
    DevTable [JC]. DevInfo.BarInfo [i] .dwSize;
    }

    Return PCICORE_SUCCESS;
    }

    As an attachment, there is the Info.vi device Get trying to access this feature. The code crashes when the function is called.

    I have probably not pass parameters of data properly to COLD LAKE.

    Thank you for your lights.

    An array of fixed size in C is equivalent to a cluster of LabVIEW that contains the same number of identical items, replace the table with a cluster. In addition, structs are always passed by reference and the C function expects a pointer to a structure, you don't need to unbundle. Skip the cluster to function as a single parameter. Try the attached revised version of your VI.

  • Two parallel executions, calling a DLL function

    Hello

    Since this test takes about 6 hours to test my USE, I plan to use the parallel model to test 2 UUT at the same time in parallel.

    I implement the test code as a DLL of CVI.

    However, to my surprise, it seems that the steps that call a DLL function actually traveled in one series, not in parallel:

    Test 2 power outlets if one enters and executes a DLL works, the other waits for the first to complete its operation and return. While the other runs on the same copy of the DLL, so that the DLL global variables are actually shared between executions.

    So if a DLL will take 5 minutes to complete, two executions in the running at the same time take 10 minutes. This isn't a running in parallel in every way.

    What I want and expect also TestStand, was to completely isolate the copies of these two executions DLL such as test two casings could run at the same time the same DLL function by arbitrary executiong their copy of the function, completely isolated from one another.

    So they separated globals, discussions, etc., and two parallel jacks take 5 minutes to run a step, instead of 10.

    Such a scenario is possible?

    If not, how can I use my test in parallel (in truly parallel) when the use of 2-socket test?

    (1) Yes, he'll call the multiple executions in TestStand calling into the same dll in memory the same copy of this DLL. Thus dll called in this way must be thread-safe (that is written in a way that is safe for multiple threads running the code at the same time). This means usually avoiding the use of global variables among other things. Instead, you can store the thread shows in local variables within your sequence and pass it in the dll as a parameter as needed. Keep in mind all the DLLs your dll calls must also be thread-safe or you need to synchronize calls in other DLLs with locks or other synchronization primitives.

    1 (b) even if your dll are not thread-safe, you might still be able to get some benefits from parallel execution using the type of automatic planning step and split your sequence in independent sections, which can be performed in an order any. What it will do is allow you to run Test a socket A and B Test to another socket in parallel, and then once they are then perhaps test B will take place on one and test one run on the other. In this way, as long as each test is independent of the other you can safely run them in parallel at the same time even if it is not possible to run the same test in parallel at the same time (that is, if you can not run test on two Sockets at the same time, you might still be able to get an advantage of parallelism by running the Test B in one take during the tests in the other. See the online help for the type of step in autoscheduling for more details).

    (2) taken executions (and all executions of TestStand really) are threads separated within the same process. Since they are in the same process, the global variables in the dll are essentially shared between them. TestStand Station globals are also shared between them. TestStand Globals file, however, are not shared between runs (each run gets its own copy) unless you enable the setting in the movie file properties dialog box.

    (3) course, using index as a way to distinguish data access are perfectly valid. Just be careful that what each thread does not affect data that other threads have access. For example, if you have a global network with 2 elements, one for each grip test, you can use safely the decision-making of index in the table and in this way are not sharing data between threads even if you use a global variable, but the table should be made from the outset before start running threads , or it must be synchronized in some way, otherwise it is possible to have a thread tries to access the data, while the other thread is created. Basically, you need to make sure that if you use global data which the creation/deletion, modification and access in a thread does not affect the global data that the other thread use anyway in or we must protect these creation/deletion, modification and access to global data with locks, mutex or critical sections.

    Hope this helps,

    -Doug

  • Call the DLL function with pointer to a simple structure

    Hello

    I try to call a function by using COLD LAKE. My problem is the function parameters that I'm trying to access.

    Here is the function and its parameter:

    typedef struct {}
    int major;
    minor int;
    review of int;
    build int;
    } VersionNumberType;

    int Comm_BTE_softVersion (VersionNumberType * pVersion)
    {
    BYTE ByBuffer [2048];

    If (!.) Comm_BTE_readYMem (byBuffer, COMM_BTE_TX14_SOFTVERSIONADDR,
    COMM_BTE_TX14_SOFTVERSIONSIZE))
    {
    return FALSE;.
    }

    //. process the response
    pVersion-> major = (int) (byBuffer [0] & 0xFF);
    pVersion-> minor = (int) (byBuffer [1] & 0xFF);
    pVersion-> revision = (int) (byBuffer [2] & 0xFF);
    < 8)="" )="" |="" ((int)="" (="" bybuffer[5]="">

    Return TRUE;
    } //. end Comm_BTE

    As an attachment, there is the Version.vi soft Comm BTE who try to access this feature. The code crashes when the function is called and labVIEW is closed.

    I have probably not pass parameters of data properly to COLD LAKE.

    Thanks for help.

    Kind regards. NewCLAD.

    Everything is configured properly EXCEPT the digital representation of the values in the cluster. They must match int, which is likely 32 bit on your platform. They are your VI, U8.

  • dll function does not

    Hi all
    I try to use the dll function and one of them always returns 1 (error), and I don't know if I'm doing womething wrong.

    the datasheet of the dll wrote:

    Prototype: int WINAPI rf_M1_authentication2 (unsigned short icdev

    unsigned char model,

    unsigned char block,

    unsigned char * pKey)

    Parameter: icdev: [IN] device ID

    model: [IN] button validate mode

    block: [IN] absolute block address

    pKey: [IN]

    password of 6 bytes

    Return: returns 0 in case of success

    Explanation: model = 0 x 60: via KeyA

    model = 0x61: via KeyB

    The prototype of my function is:

    int32_t rf_M1_authentication2 (uint8_t icdev, uint8_t model, block uint8_t, uint8_t * pKey);

    Any idea?

    Thank you

    Hello

    I finally found the solution using Labview calls to place my table in an area of memory and pass the pointer to my dll. Here is the code:

    Thank you all!

  • When to call DSDisposeHandle when you have a DLL function acting as a dynamic data DS source extensible?

    Hello

    I have a dynamic function DLL acting as a data source within a LabVIEW application (see attachment) - I use DSNewHandle to dynamically allocate an array 2D handle storage via the Manager memory LV for arrays of arbitrary in application size data. I had assumed that these blocks of memory would be willing (Magic) when appropriate by the LabVIEW built in blocks that are sitting downstream, however, is not the case for treatment and the system LabVIEW memory usage continues to increase until you quit LabVIEW environment (not just if the offending application is stopped or closed).

    So my question is how and where to mop up the table used for buffers in the treatment of the application of the chain and how do I know when the buffers are really exhausted and not be re-used downstream (for instance two 2D paintings are first grouped into a 2D complex table by the re + im at the operator complex labview - is data memory out of this totally different stage of entries or is - a) modified version of the entry tables - if they are totally different and 2D to entry tables are not wired in all other blocks why the operator not have input data banks?)

    Maybe Im going to this topic in the wrong direction have the DLL data source dynamically allocates space data tables? Any advice would be welcome

    Concerning

    Steve

    So instead of doing:

    DLLEXPORT int32_t DataGetFloatDll(... , Array2DFloat ***p_samples_2d_i, ...)
    {
        ...
    
        if ( p_samples_2d_i )
        {        // *p_samples_2d_i can be non NULL, because of performance optimization where LabVIEW will pass in the same handle        // that you returned in a previous call from this function, unless some other LabVIEW diagram took ownership of the handle.        // Your C code can't really take ownership of the handle, it owns the handle for the duration of the function call and either        // has to pass it back or deallocate it (and if you deallocate it you better NULL out the handle before returning from the        // function or return a different newly allocated handle. A NULL handle for an array is valid and treated as empty array.
            *p_samples_2d_i = (Array2DFloat **) DSNewHandle( ( sizeof(int32_t) * 2 ) + ( sizeof(float) * channel_count * sample_count ) );
    
            // Generally you should first try to insert the data into the array before adjusting the size        // the most safe would be to adjust the size after filling in the data if the array gets bigger in respect to the passed in array        // and do the opposite if the adjusted handle happened to get smaller. This is only really important though if your C code can        // bail out of the code path because of error conditions between adjusting the handle size and adjusting the array sizes.        // You should definitely avoid to return from this function with the array dimensions indicating a bigger size than what the        // handle really is allocated for, which can happen if the array was resized to a smaller size and you then return because of errors        // before adjusting the dimension sizes in the array.         ........        (**p_samples_2d_i)->Rows = channel_count;
            (**p_samples_2d_i)->Columns = sample_count;
        }
    
        ...}
    

    You should do:

    DLLEXPORT int32_t DataGetFloatDll(... , Array2DFloat ***p_samples_2d_i, ...)
    {
        ...
        MgErr err = NumericArrayResize(fS /* array of singles */, 2 /* number of dims */, (UHandle*)p_samples_2d_i, channel_count * sample_count);
        if (!err)
        {        // Fill in the data somehow
           .....       
    
            // Adjust the dimension sizes        (**p_samples_2d_i)->Rows = channel_count;
            (**p_samples_2d_i)->Columns = sample_count;
        }
    
        ...}
    
  • allocate memory and call the dll function that writes to the pointer

    Hello!

    I have a DLL that has a function as in the following example, I need to call from labview. In C, I need to allocate memory for data and of course the struct. I add the pointer and the length of the data to the struct and call the function with the struct. The function itself inserts values of the struct and affected memory. Someone at - it a working solution how this can be done with Labview?

    typedef struct Thestruct
    {
    UINT16 val1;
    UINT8 val2;
    UINT8 val3;
    DataLength UINT16;
    UINT8 * data;
    } T_Thestruct;

    MY_API status MY_API_CALL udaReceive (handle, T_Thestruct * args);

    I tried in labview (see photo), but I only got values inside the structure as well as the 1097 error, reserved memory included values as before.

    OK, I found the soluton to my own problem. Alignment on the struct must be corrected in Labview. There must be a value between dataLength 2Bytes dummy and the pointer.

  • Modified dll function does not not right

    I have a bunch of the DLL created a c# project. So far I managed to use DLL functions in Labview with the nodes in the palette of .NET.

    My problem is this, I made a few minor changes to the behavior of a function in the DLL in Visual Studio, but when I try to run this same feature in Labview, it still has the old behavior, as I've not updated at all. (I even started a new VI just to implement the nodes and the.) DLL file contains the date of last modification as a few minutes before, does still not work well)

    Does anyone know why this might be happening?

    Go to View > .NET assemblies in memory to verify the location of the DLL.

  • List of dll functions

    Hi, I tried to get the current list of all dll functions. Here is my code: tsErrChkMsgPopup (TS_StepGetModule (StepHandle, & errorInfo & cviModule)); error = TS_CVIModuleAsCommonCModule (cviModule, & errorInfo, & commonCModule); sprintf ("c:\\Temp\\%s", sztemp, szdll); error = TS_CommonCModuleSetModulePath (commonCModule, & errorInfo, sztemp); error = TS_CVIModuleSetModuleType (commonCModule, & errorInfo, TSConst_CVIModuleType_DLL); error = TS_EngineGetAdapter (EngineHandle, & errorInfo, County, & commonCAdapter); error = TS_CommonCAdapterGetDllFunctions (commonCAdapter, & errorInfo, sztemp, & dll_func); Problem was found in the last line. Direct connection between commonCModule and commonCAdapter was non-existent, so I ask for EngineHandle of commonCAdapter, because GetDllFunctions is only for commonCAdapter. Can you help me with this? Best regards, branar

    You don't need a module for a list of the functions of the DLL. Here's some pseudocode for what you need to do:

    Adapter CommonCAdapter = Engine.GetAdapterByKeyName (AdapterKeyNames.FlexCVIAdapterKeyName);

    DllFunctions functions = adapter. GetDllFunctions (path);

    for (int i = 0; i)< functions.count;="">

    {

    Function DllFunction = functions [i];

    String nomfonction = function. DisplayName;

    Do something with functionName.

    }

  • Problem with the help of DLL functions

    Hello.

    I'm writing a DLL that calls the functions of a DLL camera and them ends and passes of LabView. I wrote some code of practice and the dll of passage of functions and events with Labview and LabWindows/CVI DLLs, so I like to think I have a reasonable understanding on what I'm trying to do. However I keep getting errors in calling the functions of DLL functions camera I want to use in my DLL.

    I have two functions in the camera DLL, XC_AddImageFilter, and XC_RemImageFilter, I would like to wrap and put at disposal in my DLL. When I compile I get the following errors:

    2 link project errors, Undefined symbol '_XC_AddImageFilter' referenced in "ImageFilter.c". Undefined symbol '_XC_RemImageFilter' referenced in "ImageFilter.c".

    I tried to tweak the prototypes in my header file and the change in functions but nothing I try seems to work. I connected the camera DLL in my project in a way that was previously successful with another practice DLLs and I browsed this forum for similar problems, but I can't seem to find a soloution.

    Thank you for taking the time to read this. I hope that you will be able to help me with my problem.

    PS I had problems to join my code so I put an extension .txt at the end and apparently has worked so please forgive the suspicious file extensions.

    Sorry!

    I do not understand the Labview.lib file which is why Labview functions weren't working! Duh!

    #begginer errors!

  • Why the DLL function performed by call library node fails when the Vi is reopened?

    Development system

    OS: Windows XP

    LabVIEW: version 10.0

    DLL: Custom

    Compiler: Visual C++ 6.0

    Function prototype: __declspec (dllexport) const char * test (void)

    We have developed a DLL to use.  Compile the DLL itself.  The DLL includes a function test.  The test function validates the functional capabilities of the DLL.  I followed the examples online, and I used the tool to import shared library in LabVIEW.  The screw created use the call library node.

    When I create a VI by calling the function in the DLL test customized by using the call library node the VI runs the test DLL function flawlessly.  I close the VI.  When I re - open the VI and run it, I get an error code of the DLL.  However, if I go on the schema and define the path of the DLL in the library call Configuration node once again the VI then runs the test DLL function perfectly again.

    I have set the path of the DLL in the library call Configuration node everytime I open the VI.  The examples that I downloaded from the community don't require this.  What could be the missing DLL?  What Miss me?

    I solved the problem.

    I had create the DLL by using the following steps for VC 6.0:

    1. new project

    2. Select the Appwizard (DLL) MFC

    3. Select the regular DLLS using the MFC shared DLLS

    4 Yes for source file comments

    5 finishing

    The DLL must be on the VI search path.  The easiest way was to have the DLL in the same directory as the VI.

  • DLL function called change of entry

    Hello world

    I know that it is very basic; but I am not by my own. I am very new to LabVIEW and was not able to find a solution in the forum.

    I want to call a function in a DLL, every time when I press a button; but unfortunately, the function is called only when starting.

    So, how can I call a DLL function on a change of some of the entries?

    I have attached a screenshot. I tried the stuff. It did not work. Now, the function is called twice during startup.

    Thanks in advance and best regards,

    Chris

    If you want to call anything with a button, use a structure of the event with a value change event.

    I would recommend that you take one of the free LabVIEW tutorials available on the site and see examples of delivery - help > find examples.

  • error message trying to run a clean boot "an access error was returned while trying to change a service."

    While trying to solve a problem with IE 8, I have a problem trying to run a clean boot.  When I start up I get a message on change in the config file. Click ok and sys config is displayed. Now, if I make a modification, OR not, I get an error message - "an access error was returned while attempting to change a service. You may need to log on using an administrator account to make the specified changes. "First of all I am logged on as administrator, secondly I get this error even when I select"normal start ". I used the clean boot before without problem.  Any ideas?  I am running win xp sp3.  I started having problems after the sp3 upgrade.

    Given that you are not using the standalone SP3 Installer AND since McAfee was working at the time of installation, that's what I'd do (well, I would do it only if I was almost 100% convinced there was no malware on my system):

    1. download the McAfee removal tool.

    2. download the installation file for the free version of Avira AntiVir.

    3. download the standalone SP3 Installer.

    4. download the standalone installer of IE8.

    5. physically disconnect from the Internet.

    6 turn off the automatic updates (temporarily).

    7 uninstall McAfee.

    8 run the McAfee removal tool to make sure that all other loose ends are supported.

    9 Uninstall SP3.

    10. run the system restore, select the before date SP3 has been installed.

    11 uninstall IE8 (and IE7, if necessary). Reason: It is important to be at the level of IE6.

    12 install the SP3. Reset.

    13 Installing IE8. Restart twice.

    14 install AntiVir.

    15 re - connect to the Internet.

    16. download and install the update of AntiVir.

    17 go into Windows Update and install all post-SP3 SECURITY update (stay away from any optional object).

    18 re-rockers automatic updates.

    After the back if you need links to the downloadable.

Maybe you are looking for