DLL CALLBACK EVENT IN LABVIEW

I am developing application using Labview 7.
LabVIEW application is invoking VC++ dll.
Is it possible in LabVIEW to get callback event from VC++ dll into LabVIEW application with some data like string ?

I'm not sure that I completely understand your question, but it sounds like you are trying to take events from a DLL and pass them into LabVIEW. I've attached an example that does just this. Here is a brief description:
This example demonstrates how to post a message to the LabVIEW event structure from a DLL and how to pass it data as well (using the PostLVUserEvent() function). The VI calls the dll, which in turn passes 3 messages to the event structure. The data ( in this case, a LabVIEW string ) is displayed in a dialog window that stays open for 2 seconds. The dll is called in its own thread so it does not hang the UI thread. Refer to the "Using External Code in LabVIEW" manual for more information about the function.
The example was developed in LabVIEW 7.0 and the DLL in VC++ 6.0. Hopefully, this example gives you a good start!
Regards,
AE Sulzer
Applications Engineer
National Instruments
E. Sulzer
Applications Engineer
National Instruments

Similar Messages

  • MIDI in using DLL callback function

    I am trying to get MIDI into LV. The dll used is winmm.dll and the function midiinopen (plus others) is described here:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_midiinopen.asp
    The main problem is I don't know how to program the Call Library Function Node properly in order to perform the call
    plus set it to start receiving callback data, being midi messages. I have tried creating and registering a User Event and
    passing the Event ref to the dll's "dwCallback" and then trapping the callback in an Event Structure, but nothing happens.
    I have studied the "Communicating with a Windows MIDI Device in LabVIEW" example but it gives no hint since midi out
    does not require the use of callbacks.
    Please advice,
    Stefan

    Vedeja wrote:
    I am trying to get MIDI into LV. The dll used is winmm.dll and the function midiinopen (plus others) is described here:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_midiinopen.asp
    The main problem is I don't know how to program the Call Library Function Node properly in order to perform the call
    plus set it to start receiving callback data, being midi messages. I have tried creating and registering a User Event and
    passing the Event ref to the dll's "dwCallback" and then trapping the callback in an Event Structure, but nothing happens.
    Damn! Need to make this post shorter as this message
    board just silently told me that it needs to be shorter than 5000 words
    and ate up my lengthy repsonse with no way to get it back.
    You can't configure a Call Library Node to pass a Callback function to
    another function. Callback functions have been alien to LabVIEW for a
    long time with good reasons and what it has now as callback function in
    LabVIEw 7.1 and newer is not directly compatible with C callback
    functions.
    Basically as you want to get data from the callback function back into
    LabVIEW there is really no way around some intermediate software layer
    which in this case almost surely means your own specific wrapper DLL
    written in C.
    If you use LabVIEW 7.1 you could use user events but not in the way you
    describe. Attached is an example of how you can use user events from
    external code. Note the extra DLL you will have to write. You have to
    watch out what data you pass back to the user event as it has to match
    exactly the type you configured the user event for, otherwise LabVIEW
    will simply crash on you.
    For numerics this is quite simply and also shown in the example. For
    strings you can't just pass back a C string pointer but you will have
    to allocate a LabVIEW string handle with
    handle = DSNewHandle(sizeof(int32) + <length of C string>)
    and then copy the C string into it. For specifics about how to do this
    you should refer to the External Code reference manual in your Online
    Bookshelf. Similar rules apply for arrays or clusters for that matter.
    If you want or need to do this for LabVIEW < 7.1 there are two
    possible approaches but both are even less trivial. You could either
    create a wrapper DLL that translates your callback events into LabVIEW
    occurrences and for the data transfer back to LabVIEW you would have to
    implement your own queing too, or you could use the Windows Message
    Queue example somewhere here in the NI examples and adapt it to return
    your specific data. That would solve the data queueing more or less for
    you without having to worry about that.
    Rolf Kalbermatter
    Message Edited by rolfk on 05-22-2006 11:22 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions
    Attachments:
    userevent.zip ‏27 KB

  • How to implement a callback function using LabView's Call Library Function Node?

    I am trying to call a fuction from a SDK.dll library using the Call Library Function Node. The SDK was provided to
    me and I do not have the source code, just the .dll and .h files.
    The SdkSetPropertyEventHandler function has a callback fuction as one of its parameters. How do I implement the
    callback using the CLF node? I am a good LabView programmer but this is my first time using the Call Library
    Function Node. I have read all the info I can find on NI's web site and the discussion board but cannot figure
    this one out. I am using LabView 8.6.
    The SDK.h deacribes the function as:
    //  Function:   SdkSetPropertyEventHandler
    SdkError SDKAPI SdkSetPropertyEventHandler(
                SdkCameraRef                    inCameraRef,
                SdkPropertyEvent                inEvnet,          
                SdkPropertyEventHandler         inPropertyEventHandler,
                SdkVoid*                        inContext );
    //  Description:
    //       Registers a callback function for receiving status
    //          change notification events for property states on a camera.
    //  Parameters:
    //       In:    inCameraRef - Designate the camera object.
    //              inEvent - Designate one or all events to be supplemented.
    //              inPropertyEventHandler - Designate the pointer to the callback
    //                      function for receiving property-related camera events.
    //              inContext - Designate application information to be passed by
    //                      means of the callback function. Any data needed for
    //                      your application can be passed.
    //      Out:    None
    //  Returns:    Any of the sdk errors.
    A separate header file called SDKTypes.h contains the following data:
    typedef  SdkUInt32  SdkPropertyEvent;
    typedef  SdkUInt32  SdkPropertyID;
    typedef  void       SdkVoid;
    typedef  struct __SdkObject*    SdkBaseRef;
    typedef  SdkBaseRef    SdkCameraRef;
     SdkPropertyEventHandler
    typedef SdkError ( SDKCALLBACK *SdkPropertyEventHandler )(
                        SdkPropertyEvent        inEvent,
                        SdkPropertyID           inPropertyID,
                        SdkUInt32               inParam,
                        SdkVoid *               inContext );
    Thanks for your help.
    Alejandro
    Solved!
    Go to Solution.

    alejandroandreatta wrote:
    I am trying to call a fuction from a SDK.dll library using the Call Library Function Node. The SDK was provided to
    me and I do not have the source code, just the .dll and .h files.
    The SdkSetPropertyEventHandler function has a callback fuction as one of its parameters. How do I implement the
    callback using the CLF node? I am a good LabView programmer but this is my first time using the Call Library
    Function Node. I have read all the info I can find on NI's web site and the discussion board but cannot figure
    this one out. I am using LabView 8.6.
    Basically you do not do that. LabVIEW does not know pointers and certainly not function pointers. What you should do instead is writing a C DLL that implements the callback and also exports a function to be called by LabVIEW that translates between the callback and a LabVIEW user event. Look for PostLVUserEvent() here on the NI site to find examples how to do that.
    Rolf Kalbermatter
    Message Edited by rolfk on 02-11-2009 08:00 PM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to call this dll point function by labview

    Void SetCompStatusCallBack(void ((*CompStatusCallBack)(int id, int status, unsigned char conflict)))
    Sets up callback function for getting component status.
    Parameters:
    * CompStatusCallback – entry point for callback function.
    Return Value:
             None.

    left wrote:
    Void SetCompStatusCallBack(void ((*CompStatusCallBack)(int id, int status, unsigned char conflict)))
    Sets up callback function for getting component status.
    Parameters:
    * CompStatusCallback – entry point for callback function.
    Return Value:
             None.
    You don't. This is the callback protoype that would be passed as parameter to another API and as such never will be called by the caller of that API but instead be provided by that caller!
    And LabVIEW does not support function pointers at all, so you really can't do this.
    The only solution is to write a wrapper function in your DLL or in a separate DLL that translates between this interface and some more event oriented LabVIEW functionality such as user events, but unless you do know C to a fairly good level, you should probably leave that to someone else.
    Rolf Kalbermatter
    Message Edited by rolfk on 01-26-2007 04:21 PM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to use postlv user event in labview

    Hi sir 
     I am sending data labwindow cvi dll call to labview,for that we need postlv user event.please any one knows to use postlv user evenet in labview.
    Below will  be the  structureand i need to update in labview .
    typedef struct
    unsigned
    uDSPIO,
    // uDAQMode,
    // bControllerActive,
    bShutDown,
    bPowerOn,
    bPowerHi,
    bPowerFault,
    bSGIdle,
    bSGHold,
    uBitsIn,
    uBitsOut,
    uCycleCount,
    uCycResidue,
    uBlockCount,
    uLogChannels,
    uCurrentMode,
    uAsigndPhysCh[LOG_CHANNELS];
    float
    fSetPoint,
    fDAQRate,
    fRange[LOG_CHANNELS],
    fReadout[LOG_CHANNELS],
    fMax[LOG_CHANNELS],
    fMin[LOG_CHANNELS];
    char
    sChID[LOG_CHANNELS][32],
    sChUnits[LOG_CHANNELS][16];
    CTRL_CHANNEL_STATUS;
    Attachments:
    GDSCallback.vi ‏12 KB

    AThe fixed size arrays in your structure are inlined byt the C compiler. This means they are not an array pointer (and definitely never a LabVIEW array handle) but rather LOG_CHANNELS amount of unsigned ints and floats directly embedded in the structure. In LabVIEW terms this is most easily represented as a cluster with LOG_CHANNELS elements inside the main cluster.
    So basically your uAsigndPhysCh needs to be a cluster with LOG_CHANNELS elements of unsigned ints and  fRange,  fReadout, fMax and fin are clusters with LOG_CHANNELS single precision float values, and then sChID is a cluster with 32 * LOG_CHANNELS chars and sChUnits one with 16 * LOG_CHANNELS chars.
    However I would personally rethink this strategy. This huge cluster monster is passed into PostLVUserEvent() each time and copied into the event data on every event, causing quite a bit of overhead that way. Is it really necessary to post all this data every time?
    Also you have commented out uDAQMode and bControllerActive in your C structure but included it in the LabVIEW cluster which will certainly throw off your data. Last but not least the b prefix would probably indicate that you are only using that element as a boolean value, so why not consider to use bit fields there? In LabVIEW you can easily seperate those bitfields by either translating the resulting uInt32 into a boolean array or even more efficiently use boolean logic to detect the bits.
    And in order to let LabVIEW react on a user event you have to create that user event with the correct datatype (your cluster monster) and then pass the user event refnum to your DLL. This DLL then calls PostLVUserEvent() with the user event refnum as first parameter and a pointer to a data structure that matches the LabVIEW user event datatype EXACTLY whenever it wants to post an event to LabVIEW. The user event is also registered in an event structure in LabVIEW which will then get triggered everytime your DLL posts an event by correctly calling PostLVUserEvent().
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Register a Callback function in LabVIEW

    Is there any way to register a callback function in LabVIEW. For example:
    I have a DLL on Win2k that run a thread. This thread is doing a certain task (it is not important what it does...) I can't predict when this task will end and I need to know when the task is over. The easy way would be to poll this DLL and ask: "Is it over? Is it over?" over and over again. No! I don't want to poll. Not because it's too easy. I want this DLL to wake me up on time.
    Any idea, solutions, function that I'm not aware of, new features...
    Thanks
    Nitrof

    I think I have a much better solution for you. Here is an example program that show how to set a LabVIEW occurence in a dll. Therefore when your dll is done it can set the LabVIEW occurence, meanwhile your VI is just waiting on the occurence.
    More infomration on this is in the external code in LabVIEW manual Using External Code in LabVIEW
    NOTE:This will ONLY work in LabVIEW 7.
    Attachments:
    SetOccurDll.zip ‏165 KB

  • Create callback event bug

    I've changed my label positions to left for controls and right for indicators for a more compact and sleek look.
    BUG:
    When creating a callback event-vi, the Variant-label is placed to the right, albeit being a control ...
    In other circumstances this happens if i by mistake place a control when i want in indicator and then switch to the other type, the label doesn't change (also a bug that it doesn't?)
    Is this what's happening in the script somehow?
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

    It looks like your code is looking for a TypeDef called CtlRef.  I don't know if this is part of the IMAQdx spec, or something you need to provide, but providing it should get rid of the broken arrow.

  • Callback event for modified text file

    I am looking for a way to register, in LabVIEW, an event that signals when a text file has been changed by a 3rd party software. I could use the 'File/Directory Info' LV primitive in a loop to let me know when the file has been changed but that would be very inefficient. Does someone know of a COM object that would let me 'stream' the changes of the text file or that allowed me to register an ActiveX callback event?
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

    Archimedes wrote:
    I am looking for a way to register, in LabVIEW, an event that signals when a text file has been changed by a 3rd party software. I could use the 'File/Directory Info' LV primitive in a loop to let me know when the file has been changed but that would be very inefficient. Does someone know of a COM object that would let me 'stream' the changes of the text file or that allowed me to register an ActiveX callback event?
    If you know C/C++ well, take a look Window API: FindFirstChangeNotification.
    You can find it doc on MSDN.
    George Zou
    http://gtoolbox.yeah.net
    George Zou
    http://webspace.webring.com/people/og/gtoolbox

  • Nilvaiu.dll pas trouvé avec LabVIEW 821...

    nilvaiu.dll pas trouvé avec LabVIEW 821...
    Impossible de reprendre un vi créé avec LabVIEW 820 : pb au niveau de l'assistant DAQ.
    Merci d'avance.
    T.

    Peux être un début de solution :
    http://digital.ni.com/public.nsf/allkb/A64B6D4665F7C8C686257248001D7656
    Trouvé sur la knowledge base NI, un bon point de départ pour trouver des solutions
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • VI containing Event Structure will not receive front panel events in LabVIEW Real-Time.

    Hi again, I'm working in my first UI (attached VI).
    It works when running directly from PC. It doesn't when running from cRIO, there's the message "VI containing Event Structure will not receive front panel events in LabVIEW Real-Time". I've been reading and I found that "Event structures on RT targets do not support events associated with user interface objects, such as VI panels or controls. For example, associating the Value Change event with a control does not work. RT targets support only user events".
    Is that the problem? If it is, how can I create Mouse Up, Mouse Enter, Value Change (or other user interface events) user events?
    If I run my VI in FPGA mode should it run?
    Attachments:
    HMI.vi ‏33 KB

    Since it looks like you are new to the whole RT and machine control, I recommend giving this a good read: NI LabVIEW for CompactRIO Developer's Guide
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Callback event user_command does not exist

    can anybody assist me in this error in hierarchy alv reports..
    i got the error like
    Callback event user_command does not exist
    thanks in advance..
    bye--
    deepa
    Message was edited by:
            pradeepareddy punnam

    i got the answer

  • COGI Recording Error: 'callback event CONTEXT_MENU does not exist'

    Hello!
    Our ABAP Team is facing a weird error when they try to record COGI via transaction SHDB. They are getting the following error 'callback event CONTEXT_MENU does not exist'.
    We´ve been looking a note in Marketplace but we didn't find anything.
    Could someone help us, in order to find the solution.

    Make sure the "Not a Batch Input Session" checkbox is selected when recording.
    If you plan on using this later as part of BDC, make sure that the NOBINPT field is set to X when using "OPTIONS FROM opt" per the SAP documentation on Call Transaction.

  • Event structure react to programmatic events in Labview 7

    I originaly thought, that Labview 7 would have the option to have the event structure react to programmatic changes. That's what I thought "dynamic" support would do. Instead, it doesn't seem to be the case. Is there a way to make an even structure react to a "programmatic event" in Labview 7?

    You can do what you want, although your terminology is a little off. You can use the User-Defined Events which are new to LabVIEW 7.0 to create and generate programmatic events. There is a shipping example calling "Programmatically Fire Events." This is an example of User-Defined Evenst.
    When you say "dynamic" events, you are probably referring to "dynamically registered" events. This is different. This means that you can register and unregister an event programmatically. Now, this can either be User-Defined events or just the user interface events which are available by default. The LabVIEW Zone currently has an article up by the developer who built these feature
    s so I would suggest taking a look at that. It should help get you started on this. They're certainly a very powerful new tool, but also very advanced.
    J.R. Allen

  • Making dll from VI containing labview global variable ?

    I've made dll from VI containing labview global variable.
    But, when I write a c program calling a function from the dll, it returns just error.
    The goal is to read a labview global variables from c program. What can i do for it ?

    Hi
    If you don't use the dll in your LV app, it will be difficult, because it will be in the adress-range of you c app. So any writing of values to the global variable in LV, won't affect the variable in the dll.
    What you can do is some kind of client-server architecture. You need a third app, which just does the data exchange - so you should be able to write a value from LV and read it from c.
    There already have been discussions about similar topics - just search the forum.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...

  • Events in Labview 7.0

    Hi all.
    Can anyone provide examples of how to create programmatic (generated by the
    application rather than the user) events in Labview 7.0?
    Any help much appreciated.
    Tony

    Here is a simple example (LabVIEW 7.0) for using a signaling property to fire an event.
    The upper loop contains an event structure and one event is for a value change in an indicator (Yes, it does not need to be a control ). Under certain conditions in the lower loop, we write to a signaling property of the indicator instead of the indicator terminal and the event is triggered.
    (Writing to a signaling property always triggers an associated value change event, even if the old an new values are the same.)
    Message Edited by altenbach on 03-19-200608:55 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SignalingEvents.png ‏10 KB
    SignalingEvents.vi ‏36 KB

Maybe you are looking for

  • Web browser processes use over 100% CPU (OS 10.6.8)

    Hey, I know this problem has come up a lot in the last couple of years, but I've looked everywhere, at every thread and possible solution to my problem and none have ever worked, so as a last resort I'm going to just straight up ask bout again and ho

  • Invoice Receipt via FB01

    Hello all, I would like to ask, whether it is possible to post invoice receipt to an purchase order/SD order via the tc FB01. I know the usuall way is via MIRO. I'he tried to post it via FB01 with the document type RE, I filled the field purchase ord

  • Bluetooth modem with Mac OSX 10.5.x

    I have been using bluetooth modem of E51 and N70 with Mac OSX 10.4.x, it has been working really fine. Last week I updated Mac OSX to 10.5.2. iSync works well with Nokia_E51_1v1.dmg. But, bluetooth modem doesn't work well... Actually I can connect in

  • Error in assign expression

    Trying to copy values between two variables, we have the error message that follows. Please could you help us? Thanks a lot, Giovanni Error in <assign> expression: <to> value is empty at line 184 The Xpath expression: "/tns:rispostaVisuraFamiglia/tns

  • Different browser - different look

    Hi I have since long a website done with iWeb 08 then iWeb09 If you take this url http://web.mac.com/ragnargrippe/Ragnar_Grippe/8th.html (page with shadow) and paste it in Firefox latest version it doesn't show up correctly. Shadows are boxes, while