How to pass a pointer in calling labview library using dll programmed in Labwindows?

Hello

I'm trying to interface a camera with Labview.  However, the camera can only be programmed in C, so I use Labwindow CVI.

I need to pass a handle from the camera of a function to another, for example. leave an opencamera function to function setparameter.

/ * Loading the Qcam driver and open the first camera * /.
Sub DLLEXPORT LoadDriverAndOpenCamera()
{
QCam_CamListItem cameraList [10];
unsigned long cameraListLength is sizeof (cameraList) /sizeof(cameraList[0]);.

load the driver
QCam_LoadDriver();
a list of cameras
QCam_ListCameras (cameraList, & cameraListLength);
listLength is now the number of available cameras

QCam_Handle CMAH;
Open the first camera in the list
QCam_OpenCamera (cameraList [0] .cameraId, &hCam);)
}

Apparently, the caemraId is a long unsigned (unsigned 32-bit by 32-bit Labview 2012?) and QCam_Handle is defined as void *, so it is a pointer that points to a non signed 32 bit.

When I only use C for programming, I can pass variable CMAH to other duties so it is declared as a global variable.  Ex, the following function can be Sub SetParameter(QCam_Handle hCam).  However, here, I trying to do a Labwindows/CVI dll and then call LoadDriverAndOpenCamera() through library function call in Labview.

My question is: How can I switch CMAH to other functions in the same dll?  I have to add the parameter to the function? For example:

Sub DLLEXPORT LoadDriverAndOpenCamera(unsigned long cameraId, QCam_Handle* cameraHandle)

And then add two lines:

cameraId = cameraList [0] .cameraId;
cameraHandle = CMAH;

in the service?  So I spend cameraHandle out?  However, the CMAH will always have kind of vacuum.

Even if this is the case, how can I configure node call library on Labview?  In the arg parameter set up, I do not see pointers?  It seems that I can not put in place an exit node to be a pointer that points to an unsigned long.

Thank you very much for your help!

Best,

Charles

Hello Charles,

I noticed that you posted something similar here. you have questions about the use of the call library function node?

Tags: NI Software

Similar Questions

  • How to pass a string to a vi from a dll?

    I have a DLL that generates errors in the log. How can I display my Panel before these errors? In other words, how to pass a string from a DLL to a vi using the library to call feature?

    Thank you

    Diego

    The DLL actually allocates memory for the string? If this is the case, there should be another function to free the memory. Otherwise you won't be able to do the deallocation of LabVIEW, which means you would have to write a wrapper DLL. If you do not have the deallocation, then you will have a memory leak.

    Are you sure that the DLL is not simply wait for a buffer "of a proper size? In this case, you can simply create a U8 in LabVIEW to a size that is larger that the largest string that you expect to get.

  • How to detect programmatically something dirty in labview vi using labview scripts

    Hi people,

    I'm trying to write a code that passes by a few screws and check if they have a dirty point using labview scripting but have a moment difficult trying to find a way to do this. is it possible that I can do this? any help is greatly appreciated!

    S

    Have you tried this VI property?

    http://zone.NI.com/reference/en-XX/help/371361K-01/lvprop/vi_modvi_modificat_bitset/

  • How can I change the JPEG images and photos using the program "Paint"?

    I'm taking a good picture of me with my laptop built-in digital camera, so I can use it as my avatar on my blog page.  I tried to change it and other images using the 'Paint' program, but I am not so much with things, as brighten up my eyes and my teeth by a shade or two.   Is there someone who could give me any suggestions on the best way to do it?  When I do, I do the picture of me end up looking like Little Orphan Annie.  Of course, I appreciate all the tips and help and thanks to all who respond!

    If you need a program with more options... the
    Freeware PhotoScape can be worth a try:

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    PhotoScape
    http://www.PhotoScape.org/PS/main/download.php
    (NT/2000/XP/Vista/7)
    (the download is: PhotoScape_V3.6.1.exe)

    PhotoScape? (tutorials)
    http://www.PhotoScape.org/PS/main/help.php

    For example...

    How to whiten teeth with PhotoScape:

    Open PhotoScape and select... Editor in Chief.

    Click on the Viewer and find the picture you want to
    Ed. Left click of the photo to highlight and click on the left...
    Editor tab.

    Left click the + button to zoom in and get a good
    view of the teeth of the subject.

    Reach... Tools tab / effect brush / brighten up...

    Choose a size of brush near the size of the teeth.

    Left click / drag the toothbrush to reach...
    the brightness desired... you may need several passes
    If the result is not acceptable to the left click Cancel all
    button and try again.

    Also... you can place the brush on a tooth and the left click
    one or more times to brighten this single tooth.

    It is best to save as and give your modified version, a new name...

    See you soon

  • Serial Communication issue - packed LabVIEW library used in the Scripts of TestStand

    Hello

    I have developed a RS422 driver in LabVIEW for the basic operation is as initialize, reading, writing, closing etc. Later I used it as a library wrapped in TestStand scripts.

    The question is, when I try to read the answer to one of the command, I am able to observe it in the iteration 6th step of reading, where I'm supposed to read for the first time.

    Please suggest any ideas on what could be the reason.

    You need to know if the response data really who arrives late, after giving a command or the VI you wrote is not able to capture the correct data.

    If you have a recorder RS 422 or bus Analyzer then it will be easy to analyze the cause.

    Since you are able to read step 6 on reading a few questions:

    You are still able to read on the 6th read-only? If yes then probably the target USE responds slowly to this command or it sends too much unnecessary data that are read by the 5 first readings. (depends on your reading algorithm).

    Playback vi must be written such that it will be in a loop (with some time out) until it gets the required data. The expiration time should be configurable.

    Also before sending the order you must ensure that the buffer is empty (rinsed).

    I hope this helps.

    Ravi

  • How to reduce the size of the menuitem Application using the programming...

    Hi all

    Help me please

    If my BlackBerry device with the font size is 14(max_system_font).and then I run my application, the menu items stop looking very strange, that the font size is so great. Throughout the application, I set the font size. but unable to reduce or to set the font size of the menuitems.

    Please can someone suggest me, how to fix the font menuitem size in my application.so she gets not the size of the police system fron any effect.

    Ashutosh

    I searched a lot. but did not get any solution.

  • How to pass variables by using the command line when starting from a native application ActionScript

    How to pass in variables or arguments to start using the command line when starting a native ActionScript application? For example, I have my app MySweetWidget call and it was compiled with Adobe AIR runtime in captivity so now I have MySweetWidget.exe.

    In the command line, I call MySweetWidget.exe and would like to pass in variables or properties of the application. I guess that these variables are read from the loaderInfo.parameters object.

    Please let me know if the Adobe AIR runtime supports passing the parameters to native execution. If so, I would like to help determine the correct format of how pass variables. So would you want to read those loaderinfo.parameters object?

    Thank you

    Jeff

    I found the answer to my own question:

    Yes, it's a feature supported. It is documented on the following page:

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/desktop/NativeApp lication.html #event:invoke

    When you subscribe to the event from the NativeApplication invoke it will subsequently send the event and you read the table of e.arguments object to get the start in the native application arguments.

  • Excel 2007 to carry forward when called LabVIEW v9 in Windows 7

    I'm building a dual system using LabView and Excel 2007 v9, Windows 7.  The original system used Windows XP, Excel 2007, and LabView v8.6.  The problem is that the original system has been able to bring forward to Excel when it is called LabVIEW by using the node property - application-> visible.  This new configuration is running Excel, loads the data, run macros, but does not Excel forward.  The icon flashes in the bar of tasks Win7 and when selected displays at the top of LabView.  If I reduce the window of Labview, Excel is here.  This brings me to the conclusion that Excel is visible, as requested but will not come forward until this that selected in the taskbar.  The only differences, not to mention the versions, is used the extension .xls in model of original system files was performed in Excel in compatibility mode.  At the request of customers, the new system uses on model files Excel .xlsm extension.  I tried to use application.visible = True in the macro as well.  Could be a setting in Labview?  Could be a setting in Excel? Could be .xls vs. .xlsm? Or a problem with Windows 7 and the latest version of Labview.

    HP workstation - Labview v9 - Windows 7 - Excel 2007 sp2

    Thanks in advance

    Stephen

    SFM - dss says:

    I'll try the windowstate change.  Were these done successively? (i.e., property node-> property-> property node node) Or have they done along the way like the open call ActiveX and a property node then in a spreadsheet etc editing area, so there was some time between calls?

    I just use something like this in any place where I normally just would make excel visible. Works for me on Win7 x 64 even though I don't really know why.

    On Windows XP, I never had no problem with just using the visible property, with a change unique windowstate or even without one.

  • 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

  • error when pass array 1 d by data in table pointer via Labview-built c++ dll

    I'm trying to generate a Labview VI to a DLL and let it be invoked by vc ++, by which a 1 d array is passed. However, I can't generate the DLL when you use the data pointer to the table, which gives the error like below:

    [ERROR]
    Code :-2147221480
    Strengthening of the DLL.
    Error when compiling the DLL as a function name or a parameter is illegal. Check function and parameter names are legal C identifiers and are not inconsistent with the LabVIEW headers.
    Additional information: 9 project link errors
    Type Library generate error. MIDL.exe failed during the compilation of the odl file used to create the type library.
    Note: The error indicates that the odl file has unknown types. This error is possible when
    works with non-standard types is exported using the method qualifier exporting files in
    release the configuration that have not been recompiled during the build process.

    The Prototype of VI define is as below

    But, if I use the pointer to manage through the table, the generation is successful, error-free. I write something to call the DLL built labview, which basically reads 1000 double the data of an instrument.

    #include "TestDQMaxDLL.h"
    #include 
    
    using namespace std;
    
    int main(int argc, char** argv) {
        cout << "Start testing DQMax DLL" << endl;
    
        int leng{ 1000 };
        DoubleArray rawDPData = AllocateDoubleArray(leng);
        test_dqmax_dll(&rawDPData);
        cout << "Successfully invoked the DLL!" << endl;
        cout << "DoubleArray.len: " << (*rawDPData)->dimSize << endl;
        for (int i = 0; i < leng; i++)
        {
            cout << (*(rawDPData + i))->elt[0] << "\t";
            if (0 == i % 10)
            cout << endl;
        }
    
        system("pause");
    
        DeAllocateDoubleArray(&rawDPData);
    }
    

    But the printed results are not correct.

    My questions are:

    1. why cannot generate DLLS with the data of table pointer. In this case, the argument of the function is as simple as a double array.

    2. for table handle pointer, when the resutls are incorrect and how to get the good ones.

    Any comments would be appreciated.

    BTW: I use Labview 2012 with Visual c ++ 2013 on Windows7 64 bit.

    I never needed to pass a table of LabVIEW handle external code. Search this forum for posts of RolfK, it is most likely to have posted such an example. I recommend that you keep things simple and remodelling your table a table 1 d 2D before moving on to external code and manage as a 1 d table (it's just a little extra math).

    Sorry I don't have a solution on why you can't build with a 1 d as a pointer of table table. If you post your project I'm happy to try to build (I'm on LabVIEW 2012, however), but as you said, it will rely on another machine, it seems more likely to be a problem with something on the specific computer where there is a problem.

  • How to pass pointers around labview

    Hello

    What is the proper way to pass pointers, pointing to the DLL allocated memory around labview?

    I spent some time with the cast of type C standard working as:

    typedef struct
    {
        void *mem;
    } myVars;
    
    int InitMyVars(int64_t *myVarsLVPtr)
    {
        void *myVarsPtr = NULL;
        myVarsPtr = malloc(sizeof(myVars));
        if(myVarsPtr)
        {
            *myVarsLVPtr = (int64_t)myVarsPtr;
            return 0;
        }
        return -1;
    }
    
    int UseMyVars(int64_t *myVarsLVPtr)
    {
        void *myVarsPtr = NULL;
        myVarsPtr =(void*)*myVarsLVPtr;
        //return funcWithVars(myVarsPtr);
    }
    

    Subsequently set up nodes to call library as follows:

    And pass the pointer on labview as a 64-bit number (since it's a pointer, I value, it makes no difference if its signed or not signed, please facepalm me so bad)

    In this way is very ugly. I don't like it. Found several discussions, saying that "whenever someone writes a code like int tmp = (int)(&something); a little fluffy kitten chokes to death." Unfortunately, so far of programming was a certain felinicide. "It makes me a kittenchoker series.

    It is also dangerous for the different platforms, for example. i686 and x86_64.

    I was self learning all that now look back at it, it's like if I missed something some time.

    There must be a better way.

    I am grateful for the suggestions.


  • How to pass the Visa Resource Name parameter to labview dll in labwindows/cvi

    Hello world

    I build a dll of labview, the prototype is: double getchannelpower (double f, uintptr_t * VISAResourceName);

    I don't know how to go from VISAResourceName to this function.

    Is it related to the ViPSession paremeter in function viOpen(REES ViSession, rn ViRsrc, ViAccessMode am, ViUInt32 ti,ViPSession vi)?

    BRs,

    lotusky

    Hey, guys:

    I figured out how to pass the parameter.

    In labview, you must replace the control of visa with string control. In this way, the generated dll function at the entrance of the string type.

    I hope this will help others!

    lotusky

  • How to pass an xml CDATA in the string element when OSB call a webservice?

    How to pass an xml CDATA in the string element when OSB call a webservice?

    I have a business service (biz) this route to exploitation of a Web service.

    An example of this legacy Web service request:
    < soapenv:Envelope xmlns:soapenv = 'http://schemas.xmlsoap.org/soap/envelope/' xmlns: ex = "example" >
    < soapenv:Header / >
    < soapenv:Body >
    < ex: run >
    < ex: arg > <! [CDATA [< searchCustomerByDocumentNumber >
    < documentNumber > 12345678909 < / documentNumber >
    [[< / searchCustomerByDocumentNumber >]] > < / ex: arg >
    < / ex: run >
    < / soapenv:Body >
    < / soapenv:Envelope >

    type ex: arg is a string.

    How to pass this structure CDATA webservice in OSB?

    Steps to resolve this problem:
    1 create an XML schema. For example:


    elementFormDefault = "unqualified" >


              
                   
                        
                             
                             

                        

                        
                             
                        

                   

         

         

         
         

    With this XSD, XML can be generating:


    documentNumber

    2 create an XQuery query to create a ComplexType searchCustomerByDocumentNumber. For example:
    (: pragma bea: element global-element-return = "searchCustomerByDocumentNumber" location = "searchCustomerByDocumentNumber.xsd" ::))

    declare namespace xf = "http://tempuri.org/NovoSia/CreateSearchCustomerByDocumentNumber/";

    declare function xf:CreateSearchCustomerByDocumentNumber($documentNumber_as_xs:string)
    as {(searchCustomerByDocumentNumber)}

    {$documentNumber}

    };

    declare the variable $documentNumber as XS: String external;

    XF:CreateSearchCustomerByDocumentNumber ($documentNumber)

    3. in your step in proxy pipeline add to assign the created the XQuery function call from the number of the document of your payload.
    Assign to a variable (for example: called searchCustomerByDocumentNumberRequest)

    4. create an another Transformation of XQuery (XQ) to create a request to the existing Web service. For example:
    {fn - bea: serialize ($searchCustomerByDocumentNumberRequest)}

    For more information about xquery Serialize function:
    41.2.6 fn - bea: serialize()
    You can use the fn - bea: serialize() function if you need to represent an XML document as a string instead of as an XML element. For example, you can share an XML document through an EJB interface and the EJB method takes the string as an argument. The function has the following signature:

    FN - bea: serialize($input as item()) as xs: string

    Source: http://docs.oracle.com/cd/E14571_01/doc.1111/e15867/xquery.htm

  • How to load a pointer data memory in table

    I'm trying to interface to a DLL used to manage a piece of hardware. The DLL is written in c. uses _stdcall and the Import Wizard has hooked up with success of most screws in a library; many of them work everything just as it is. I have also played with the knot of library function call and think that most of the time, I got the hang of it. I ran successfully for the odd Windows API call (e.g., MessageBox). However, I am a newcomer in Labview. My problem is related to a DLL function that requires a pointer to a block of memory, in which he then dealt with the material (in the form of table of UINTs) data. I want to display these data in Labview, through a table I guess. I think I found everything I need to do in terms of creating a table and hanging until the node of library function call with an input pointer.

    I hope this would work IF the block of memory has been fully completed until the function has returned. HOWEVER, this is not how the DLL function. It creates a thread that exert to put data in the memory block after the function in the DLL. Extra features are available for face to discover if the data transfer is complete. I guess this is enough to refute the marshaling of data in Labview, unless there is some special commands for this purpose.

    I thought maybe I should allocate the memory using the Windows API (LocalAlloc LPTR flagged so I get a pointer) and I wrote a little VI that allocates and releases the memory that seems to work. This way I can release memory when the transfer is complete. MY PROBLEM is, given the pointer to the block of memory, as returned by LocallAlloc, how can I get Labview to read the memory in an array of integers.

    I am now a little stuck and would like to receive advice on one, how to convert the block of memory, or on a way to approach things btter.

    TIA

    SteveJM wrote:

    So I have a working solution, which is basically the same idea as your suggestion, but uses the Windows API. I took the trouble to mention it, but when I looked more closely at 'MoveBlock', 'DSNewPtrt' etc, I realized that they are a static C library. This means that using them requires that you have a C development system and knowledge how to build DLLs on that. As it happens that causes me a problem, but it seemed like a hammer in this case because the routines you need are already in the kernel32.dll module. [Yes that makes specific Windows, but then you would need rebuild your dll for each operating system in any case].

    This paragraph is completely inaccurate.  These functions are integrated into the runtime LabVIEW, without which your LabVIEW code will not work.  You have the guarantee that if you can run your LabVIEW code, or in the development environment or as a compiled application, these functions are available.  No need for a C development system (if that were the case, don't you think someone would have mentioned in one of the many messages on this forum on the use of MoveBlock?).

    SteveJM wrote:

    It is true that you need to find a way to pass the pointer to the destination of reference. In other words, using a "handful" I guess. One of the difficulties is that the documentation for Labview is rather imprecise on what happening coming in and out of the function call. Unfortunately, the meaning of "Handle" is very dependent on context, so documentation should be much more detailed. If you select 'Manage' rather than "Pointer table" minimum size box disappears implying that Labview will take a pointer to a pointer to a format of Labview. It would then allow the size information in the allocation of the table and set the offset pointer approprately when passing a pointer to the function that would fill the memory. If the size of the table was large enough, it might be useful to tweak with this to avoid the copy useless (and allocation), but I don't have time now, unless I find the best literature which explicitly explains this gathering takes place for each option in the dialog box.

    All the help you need is available.  Set up a call library function node to pass by handle, close the configuration dialog box, right-click on the function call library node and choose Create .c file...  You will get a draft of C with all structs defined for you, and you will see that the handful of LabVIEW table includes size information.  There is no "triage."  He is just passing pointers autour (and a few and Word-permutation of bytes due to problems of "endianness").  When you pass an array of pointer to array value, you get what you expect - LabVIEW dereferences the handle once and passes the pointer of table.  It's exactly like a C function call.  Nothing unusual occurs when the call is returned (with the exception, even once, "endianness" switch if necessary).  That said, it's a bad idea to do what you want to do with a handle, because LabVIEW is allowed to move the table when he likes and has no way to know that some other functions still has this memory block to stay where he is.

  • Call a C-built DLLS in LabVIEW

    Hello!

    I try to get knowledge on how to call DLLs in Labview.

    I found a very good example on this site:

    http://zone.NI.com/DevZone/CDA/EPD/p/ID/1513

    I downloaded and extracted the call_c_dll_in_lvnew.zipfile.

    When you try to open the sample file GenSortRandC.vi in the folder LabVIEW_code_and_DLL

    I get the following error message.

    "The procedure entry point not found RebootRTSystem in the library cvirte.dll dynamics."

    I searched on the Internet and some forums but so far without success.

    Could you please let me know if you have the same problem the example whith?

    I have the following configuration:

    -Labview 8.5.1 FDS (default installation)

    -Windows XP sp3

    Best regards

    Mattias

    Sweden

    Mattias salvation,

    I have no problem with this example. I can't run without error.

    It's maybe because I installed the CVI Run Time engine.

    Mike

Maybe you are looking for