LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView user-event from external dll source

Andrey,

 

Would it be possible to post your code for the example shown? I've studied the linkyou referenced and while it's very similar to your example, it's not quite the same. It would be helpful to see how it's done with numerics rather than strings. I'm pretty new to callbacks and all the information I can get would be helpful.

 

George

0 Kudos
Message 21 of 56
(1,986 Views)
For a numeric you simply pass a pointer to the correct type of numeric to PostLVUserEvent(). That means a pointer to double or float or one of the integer types depending what type of numeric you used to to configure the user event in the LabVIEW diagram.
Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 22 of 56
(1,985 Views)

Since I know very little C I thought it would be helpful to see the C code (the LV part is completely obvious to me). I'm sure what you said would be totally obvious to someone intimately familiar with such procedures, but not me. Since this is a fairly unique application there's not a lot of other places to look for information. There are several things being setup in the LVUserEvent example and I'm not sure which of them need to change for a different data type.The MixeCluster example in another thread probably explains some of what I need - and I'll study it some more, but the added complexity of the cluster adds another layer of confusion that I don't need right now.

 

George

0 Kudos
Message 23 of 56
(1,979 Views)

The Create User Event function node has an input called "user event data type". This is were you define the datatype of the associated data element that goes with the event. This data type has to match the data type you pass to PostLVUserEvent, otherwise bad things happen.

 

If you want to have an idea how the declaration of the data parameter to PostLVUserEvent() should look like you can wire the according data element (numeric, string, cluster)  to a Call Library Node whose parameter is set to Adapt to type. Now right click on the Call Library Node and select "Create C file", If you now look inside the created C file you will see the C datatype to use to match the actual LabVIEW datatype exactly.

 

If skalar datatypes (floats, integers) already pose problems to you, you should maybe find someone who can do this part of the project for you. Callback functions are not exactly beginners stuff for C programmers. There are many pitfalls and trouble ahead that go definitly far beyond understanding the basic C datatypes.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 24 of 56
(1,976 Views)

Rolf,

 

Thanks for that hint and for all the other help. Your expertise is very much appreciated.

 

George

0 Kudos
Message 25 of 56
(1,974 Views)

Hello,

I was just wondering if it is also possible to use the PostLVUserEvent  with LabVIEW Exes running with the  RunTime?

Thanks

0 Kudos
Message 26 of 56
(1,877 Views)
Why would you think it can't be used in a runtime application either?
Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 27 of 56
(1,854 Views)

Hello Rolf,

 

I just now looked into the examples and saw that a reference of the user event is passed to the dll. So it should also work in an exe.

 

I am not sure so far if I can use this approach in my problem. Is it also possible to send events to a LabVIEW exe from a dll, when the dll is not called from the LabVIEW exe?

 

Is this an effective way to transport data between LabVIEW and other processes? I was thinking about using this mechanism to send data from a dll data acquisition process to a LabVIEW exe.

 

Thanks

0 Kudos
Message 28 of 56
(1,821 Views)
No you can't call LabVIEW manager functions from non LabVIEW processes. The LabVIEW manager functions are implemented by the LabVIEW runtime kernel and not by labview.lib. In order for labview.lib to link to the LabVIEW manager functions in the kernel, the process that calls these functions must be a LabVIEW process (LabVIEW development system or LabVIEW runtime).
Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 29 of 56
(1,818 Views)

I am trying to pass a Cluster back through LVPostUserEvent, as a C Struct.  The struct/cluster is just a string and a double.  I have gotten the string to be correctly handled, but the double is just coming through as random garbage.  I tested it with just a double being passed back through LVPostUserEvent, and it worked just fine on the labview side, the event was posted fine and no garbage.  I then tested it with a cluster of an int and a double, and they both are garbage.  Do you have to treat each element as a handle, and call DSNewHandle for each element?  I understand why arrays and strings have to inform the memory manager, but do a simple int or double need to as well? 

 

 

0 Kudos
Message 30 of 56
(1,738 Views)