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.

Tags: NI Software

Similar Questions

  • 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.

  • How to call the java function with javascript setting in mobile adf?

    How to call the java function with javascript setting in mobile adf?

    The ADF Mobile utility container API can be used from JavaScript or Java.

    Application container API - 11 g Release 2 (11.1.2.4.0)

  • 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.

  • Call the library function does not find the DLL in the directory where are my LLBs

    I'm using LabVIEW 8.6.  I have a set of screws in several LLBs.  All LLBs located in a directory.  Most of my screws is wrappers for the functions in a DLL.  I was told to put my DLL in the directory where are the LLBs, and apparently this is how the previous programmer has worked (using an earlier version of LabView).

    In the configuration of the library call, I've specified .dll without path.  (This is how we want our screws are an API that will integrate other programmers, so I don't know where they put things and I can't use absolute paths).

    When I insert the VIs in LabVIEW, LabVIEW can not find the DLL and wonder of spotted.  It's just that here in the directory with the LLBs and when I double click on it, everything works fine.  However my absolute path to the DLL now appears in the library to call configuration, and we don't want that.

    Does anyone know how to make this work?  I guess the location of the screw (or LLBs, in this case) should be the current directory and thus Windows search there for the DLL.  However, it seems that this is not the case (in the least, in the latest version of LabVIEW).

    Thank you.

    Batya

    Well someone using your library should not have to dig into your screws and do it all on his own. Instead your library must wrap that and hide disorders it altogether.

    The cluster of error has been added when the dynamic path option has been added. It is not useful hide this error output, so it's always there. As well as the dynamic path, there was the improved error handling added the CLN. One of them is that the level of verification when calling function errors (exception handling) can be specified. I guess that some of these options may generate an error code instead of bring up a dialog box, as they did before and that the output of error code can be useful even in the case of static calls.

    As to what you want to do, I would have long managed that with a DLL that has essentially the same functions as your other wrapper DLLs and an initiliasation function that returns a pointer to a structure of functional distribution based on the actual DLL you want to call. Quite like what an object-oriented function dispatch table is. Then, when your interface initilising you call initialize function and specify the device interface/type that you want to use and after that all other functions take a pointer extra function parameter expedition as the first parameter, in addition to the parameters of the real function. This dispatch function pointer would be just a pointer to a structure that contains the table of function for this interface pointers and the sake of LabVIEW would simply be an integer of size pointer.

    The wrapper function then checks the pointer structure validity send feature and call the actual function with the remaining parameters. It is a C programming and may require a planning and desigining the different interfaces to facilitate this kind of technique of the expedition, but it will certainly pay to long-term and make your library even can be used in previous versions of LabVIEW, so that VB etc. without delicate dynamic loading in the level high, programming environment.

    Rolf Kalbermatter

  • How to call a DLL function that has need of an array initialized structures which can be written in by the DLL?

    I need to call the following function in a C DLL:

    __declspec (dllexport) int MSIL_EnumSpectrometers (SPECTROMETER_ID * spectrometers);

    where the only parameter is a pointer to:

    typedef struct
    {
    tank model [32];
    series char [32];
    Channel int;
    } SPECTROMETER_ID;

    Before LabVIEW 2011 I would use a CIN allocate the memory and call the function, but in LabVIEW 2011, the INC has been deleted and I have to use a library function node call instead. When I go to set the parameter, it seems that I need to set the type to "Adapt to the Type" and data for 'Pointer to data in table' Format, then pass an initialized array of SPECTROMETER_ID with the many elements he so the DLL can fill the table with data. (See the attached picture.) When I do that, however, it blocks LabVIEW desktop.  I guess it is because the DLL is corrupting the memory space of LabVIEW, but I don't see why, because I'm basically passing in a void pointer to an array initialized in the right size. Note that the first node of NSI returns the number of elements required in the table.  Anyone have any idea what I'm doing wrong here?

    In LabVIEW, when a table is in a cluster - cluster don't detain actually table but sort of a pointer that points to the table. If you need the cluster to contain 32 to 32 Add to the cluster. See the VI attached to how it's supposed to be done.

  • External function with a pointer to a callback within a DLL function

    Hello.

    I am loading a DLL and try to call a function with the following prototype:

    Func1(HANDLE, hHandle, LPVOID (*pCallback)(UINT, UINT LPVOID), CHAR* sPath)
    

    Now, I have no problem with the types of variables, because CVI 9.0.1 recognizes each of them and I have no problem with LoadLibrary() and GetProcAddress().

    But, how to pass a pointer to a callback function that is inside the DLL, I am trying to use.

    I tried to declare the callback like this:

    LPVOID (CALLBACK Callback)(UINT iDevNo, UINT evEvent, LPVOID pData);
    

    and call the Func1 function like this:

    (Func1)(hHandle, &Callback, NULL);
    

    but it irritates me:

    Symbol not defined "_Callback@12" referenced in "source.c.

    Hopefully I can help.

    I appreciate your time on this issue.

    Kind regards.

    Hi Daniel,.

    He must first make sure that the callback function is exported by the DLL, so the program that uses the DLL can access the identifier of the function name. Then you must make sure that you call GetProcAddress not only on Func1, but also on the exported callback function. You must store the two address function values in their respective function pointers. You can then pass the pointer to callback in the form of argument to the call to Func1.

    It's probably cleaner if you set of typedefs for all your function pointers, in the calling program:

    typedef LPVOID (__stdcall * CallbackType) (UINT, UINT, LPVOID);
    typedef? (__stdcall * Func1Type) (HANDLE, hHandle CallbackType, CHAR *);

    ...

    CallbackType CallbackPtr;
    Func1Type Func1Ptr;

    ...

    dllHandle = LoadLibrary ("... ») ;
    CallbackPtr = (CallbackType) GetProcAddress (dllHandle, 'Callback');
    Func1Ptr = (Func1Type) GetProcAddress (dllHandle, "Func1");

    ...

    Func1Ptr (..., hHandle, CallbackPtr, NULL);

    Boa kind!

    Luis

  • 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 in BT (usbm.dll)

    Hi all

    I'm having a hard time finding how to call a DLL in Labview. I read a little bit on this subject but am still a beginner. The DLL in question is usbm.dll (http://www.usbmicro.com/, the list of functions & types is documented here). I use the call library node to call the DLL.

    So I call things with no input argument functions work well (for example my first 2 calls check for the presence of the device and the number of devices and work ok returning the correct output)

    Then I try to use functions with arguments (3rd stage of the VI) and Labview does not have them (error 1097). I'll for function "int USBm_DeviceValid (unsigned char device)", in my opinion, that argument must be of type uint8 and output type int8... I tried all numeric types, does not.

    In addition, if I skip the VI 3 and go to step 4 (calling a function that takes 2 parameters and sends a command to my device): the function is executed (for example the unit move), but then Labview block (exits without error message). Is it because of calling the function?

    Any suggestions would be welcome, thanks!

    Hi lvrat, thanks for your suggestions.

    I had the problem. I got an older version of this DLL usbm (as well as some example of LV files) which works very well. Looks like the DLL most recent that I was using has some issue with Labview...

    I enclose these files (they were not easy to find), in case someone else tries to interface to a USBmicro device.

  • SubVIs called screw embedded in a DLL must be located at the opening of a VI that calls the DLL

    I have compiled a DLL that contains two exported screws calling subVIs that calls another DLL that contains hardware dongle functions.  The build DLL works fine and the two screws work fine as source code.  The reason why I want to build a DLL, it is avoid distributing the source dongle screws in order to make the two functions called more sure.  However, when I try to open a VI that makes a call to one of my two functions of the DLL (screws exported), LabVIEW try to find all the subVIs called by VI exported in the DLL.  This suggests that the DLL does not contain the subVIs - probably each VI called by the exported screws must be built in the DLL - or am I completely wrong?  I tried setting all the subVIs and the dongle DLL like 'always understood' and even export all the subVIs too.  The constructor of the DLL is able to include the entire hierarchy of VI in the DLL?  Am I missing a special combination of parameters?

    To summarize my approach:

    A first level VI (to provide an end user with password protected diagram) calls my DLL (two functions are exported screws) that call subVIs that call the DLL dongle.  I want only to provide my DLL and the dongle DLL, NOT all their source code is linked.

    Any help would be greatly appreciated, that this problem has ceased completely in my development.

    Mike

    After traveling through the builder application LAVA forum, I found a post that discusses a problem of construction of the Advanced setting 'Use LabVIEW 8.x file layout'.  This should be checked to make the build work.  Apparently R & D already know the problem (# 158487).  Moreover, previous projects of 8.6 will have this checked by default, which makes them to build properly.

    The new application now works correctly.

    The problem of generation original DLL is also fixed.

  • Help! How can I call the Matlab file with toolbox (matlab 7.1) in labview 8.6?

    Hello

    I developed a file matlab to optimize a system, it's Toolbox. Entries should be in Labview but also the outputs should be included in the labview graph.  The results include arrays. CVI is not installed. My labview is version 8.6. MATLAB is version 7.1.

    (1) is the version of labview and matlab questions in this problem?

    (2) what is the best solution? Matlab script? DLL? Active X?

    (3) if I could use matlab script, I define the type of each variables in labview, including those of the code?

    Thank you!

    Jessie

    Step 1: Learn patience. This forum provides no immediate technical assistance. It is composed mainly of volunteers, and most of us have full-time jobs.

    (1) is the version of labview and matlab questions in this problem?

    Not really.

    (2) what is the best solution? Matlab script? DLL? Active X?

    Any of these will work. If you want to use the script, then you must use the Matlab Script node. This allows you to enter the Matlab code directly in the node, or you can call scripts that you have on your file system. This method requires that you have MATLAB hand whole on the target computer. If you create a DLL Matlab, then you use the node library function call and call the DLL as any other DLL. This method simply requires that you have the Matlab Runtime on the target computer.  I assume when you say that you're referring to writing your own ActiveX ActiveX component?

    (3) if I could use matlab script, I define the type of each variables in labview, including those of the code?

    I don't know what you mean by defining each variable type. You need to create the entries and exits on the Script node Matlab, so you can pass data between LabVIEW and Matlab environment. The help of LabVIEW contains more information on the use of the Matlab Script node. There are also some examples with LabVIEW.

  • The 193 Win32 API error. Cannot call the C function: private_load_AgCoreTest

    Hi guys,.

    When I try to run Lightroom, I get the following error messages:

    • Win 32 API error 193 ("(erreur inconnue)" ") when you call: load the getCFunction library
    • Cannot call the C function: private_load_AgCoreTest

    So I can't access my library or to make a new library by importing files.

    I run it on a laptop with Windows 10 64-bit, Nvidia GeForce 850 m GTX and a processor Intel Core i7 with 12 GB of RAM and a 500 GB SSD (Samsung 840 EVO). All with the latest drivers.

    I tried already to unninstall and reinstall the program, all my packages of Visual C++ and the dll. I also already checked my permissions for the folder from catalog and granted full access. I also tried to run Lightroom as administrator.

    None of these solved the problem.

    What should I do?

    According to the notes, they followed the instructions here to fix the problem: error: "unable to start correctly (0Xc000007b)"

  • JavaScript exception: error calling the selection function: TypeError: $(...). museMenu is not a function

    Since the update, one of my sites is weird. When you open the Web, that's what he said, "JavaScript exception: error calling the selection function: TypeError: $(...).» museMenu is not a function ". The site is www.hibiscuscuisine.com. If someone could help me understand this point, I would really appreciate it. Thank you

    Hello

    Please follow the complete instructions mentioned in this post - MuseJSAssert: error calling the function switch: TypeError: .museMenu $(elem) is not a function by Zak.

    Let me know if it works

    Thank you

    Ankush

  • Call the web service with Digest authentication

    Hello

    I JDevelper 12.2.4, I need build the java class to call the web service with Digest authentication.

    Any suggestion?

    Refer to:

    http://StackOverflow.com/questions/14896324/consuming-WCF-service-with-Digest-authentication-from-Java

  • How to call the javascript function in ADF

    I have the javascript function stored in a .js file external (try to reuse in another application). How can call the javascript function for an event of ADF faces component. I need to I am a newbie to ADF, all ideas are appreciated.

    Kind regards
    Surya

    Published by: sgodavar on Sep 24, 2010 11:44

    Include JavaScript to the jsff/jspx as page:

    Call it like:

    Type = "dblClick" / >
    Amit

Maybe you are looking for

  • A previous version of Firefox killed Zone Alarm - this problem has been corrected?

    During installation, the previous version of Firefox update, it showed a box on the screen saying that he had found a file mismatch in the ultimate security alarm Zone and has been deleted. Without more explanation - and no way for me to say 'yes' or

  • Pavilion p6-2387ea: win7

    Hello I have just downgraded to win 8.1 64-bit to win 7 64 bit but when on win 7i have no drivers for usb 3 and some on the internet, plus any help would be great

  • cannot use external hard drive 1 TB for readyboost

    can I use my 1 TB WD external hard drive (fat32) for readyboost... I have win 7 home premium (64-bit) & 2 GB of RAM right now I get a message saying that this device (1 TB drive) cannot be used for readyboost... but I can easily use readyboost when I

  • Fastest way for debugging on the device of JDE

    Hi all I'm new to the development of BB and struggling to find a way to debug on device effectively.  My application has a lot of comm of bluetooth in him so most debugging should occur on the device instead of Simulator (please, correct me if this i

  • Site to site VPN - cannot see host

    Hi all Site to site VPN is established by Cisco 887 (PPPoE) on the two site. The tunnel is UP. Personnel (192.168.5.33) PC I can ping to 60.a.a.54. But I cannot ping the inside interface (192.168.0.1). I need to access the server site B (192.169.0.15