LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView user-event from external dll source

Hi, Cs.Nemes,

You can use any C compiler for creating the DLL - Microsoft Visual C, National Instruments CVI, Intel C compiler, etc.

Refer to following documents:

Building a DLL with Visual C++

Creating a Dynamic Link Library (DLL) in LabWindows/CVI 8.5 for use with LabVIEW 8.5.

include files as well as libraries located in <Program Files>\National Instruments\LabVIEW x.x\cintools

best regards,
Andrey.

Message 11 of 56
(2,943 Views)
I found them meanwhile... Thanks anyway.
Finally I managed to do it. Now I see clearly.
I very much appreciate your help! I hope at least this topic will be useful for others, too.

Best regards:
Csaba Nemes
0 Kudos
Message 12 of 56
(2,939 Views)

Hi Wiebe,

         From your answer i have a doubt that What it exactly means "If the dll is used from within LabVIEW". Also i want to know Is there any way to access the functuions defined in the .SYS file in Labview Environment.

 

Regards,

Jagan

0 Kudos
Message 13 of 56
(2,768 Views)

2716jag wrote:

Hi Wiebe,

         From your answer i have a doubt that What it exactly means "If the dll is used from within LabVIEW". Also i want to know Is there any way to access the functuions defined in the .SYS file in Labview Environment.

 

Regards,

Jagan


Can you be a litte more specific with your first sentence. I have no good idea what you mean.

 

A .sys driver is usually a kernel device driver. This driver has to be started and run in the kernel subsystem which LabVIEW can not access directly. Such a driver is initialized using the CreateFile() Windows API. The returned handle is then used with other API functions such as ReadFile(), WriteWile(), DeviceIoControl(), and finally CloseHandle().

Theoretically you could call all this APIs directly from within LabVIEW using the Call Library Node. In practice you do not want to do this even for fairly simple kernel drivers since the parameters for those APIs do get fairly complex in most cases, and you usually do also want to have some sort of asynchronous operation using events or such to make the driver access user friendly. All these things are most easily handled in a user space DLL written in C that exports a more LabVIEW friendly API that you can then import into LabVIEW using the Call Library Node.

 

Usually most kernel device drivers do come with a accompagning user space DLL already, as this is the only sensible way of accessing such a driver. So you can usually look for the documentation of that user space DLL API and go from there trying to import that into LabVIEW using the Call Library Node. Even then it may not be easy at all if that API uses complicated function parameters and even completely impossible if it uses callbacks or such, requiring you to write a so called wrapper DLL that translates between the native API and a more LabVIEW friendly API.

 

You don't have to believe me but I can guarantee you that if writing such a user space DLL or wrapper DLL is beyond your capabilities, trying to go directly about accessing the Windows APIs in LabVIEW to access a kernel device driver is going to make you squirm in real pain. And those knowing how to write such a DLL would never even consider spending the time to try to access a kernel device driver directly from LabVIEW.

 

Rolf Kalbermatter

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 14 of 56
(2,764 Views)

Iam using labVIEW 7 Express, from where i can get the GenerateLVevent?

 

0 Kudos
Message 15 of 56
(2,654 Views)

2716jag wrote:

Iam using labVIEW 7 Express, from where i can get the GenerateLVevent?

 


If you talk about the PostLVUserEvent() C API, then you can't. This API got introduced in LabVIEW 7.1, which is not so strange considering that the event structure and user events got only introduced in 7.0 (your Express version).

 

Rolf Kalbermatter

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 16 of 56
(2,649 Views)

Rolf,

Then how can i handle event from external dll.

 

Jagan

0 Kudos
Message 17 of 56
(2,646 Views)

2716jag wrote:

Rolf,

Then how can i handle event from external dll.

 

Jagan


The only options before LabVIEW 7.1 are either using occurrences (the Occur() API exists for as long as LabVIEW 3) or if an event alone is not enough and you need to also pass data back to LabVIEW with the event you have to implement your own queue in your C library. On callback you post an according event in that queue and trigger an occurrence. In LabVIEW you must have a VI somewhere waiting for that occurrence and when triggered it calls another export from your library that retrieves a queue element and returns it into your application.

 

Unless your worktime is unpaid an upgrade of LabVIEW would be certainly cheaper.

 

Rolf Kalbermatter 

Message Edited by rolfk on 02-17-2009 10:42 AM
Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 18 of 56
(2,633 Views)

Rolf,

Can u explain me how to set occurence from external dll to labVIEW?

and data from external dll to labVIEW front pannel how the queue is implemented.

 

-Jagan

0 Kudos
Message 19 of 56
(2,625 Views)

2716jag wrote:

Rolf,

Can u explain me how to set occurence from external dll to labVIEW?

and data from external dll to labVIEW front pannel how the queue is implemented.

 

-Jagan


You will have to pass an occurrence refnum to the DLL somehow. Then call the API void Occurr(LVRefNum) on that refnum. For implementation of queues please read a standard C/C++ programming tutorial. They are quite a basic component most serious C programmers should know.

 

Rolf Kalbermatter

Message Edited by rolfk on 02-17-2009 05:58 PM
Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 20 of 56
(2,613 Views)