LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling external api from call library function

Hello,

 

I have trouble to communicate with a USB device thought call library function. My cypress chip is installed to the ezusb.sys driver and is be able to communicate with the ezusbsys.h file. (Have communicated with my device thought a CIN but the program shown not stable enough)…

 I have read trough some parts of the “Using External Code in LabVIEW” which briefly describes how to act:

“Instructions on including a header file xbus.h. Although LabVIEW

does not permit you to include such header files, you can open header

files and extract information about function prototypes and constants.”

 

Nothing that I have tried with have worked and hopping now that someone else has worked with something similar.

Links, examples and tips are happily received.

 

 

Best regards,

Jonny

0 Kudos
Message 1 of 7
(4,862 Views)
As the document points out, header files are useless in LabVIEW in terms of operation. Their only purpose to a LabVIEW programmer is information for the programmer. With LabVIEW you need a DLL or a CIN that you either get from the manufacturer of the device or that you create yourself. You mentioned having made a CIN but that it's not "stable enough". Can you elaborate?
 
As for tips and examples, there's lots on the NI site. Just do a search:
 
 
0 Kudos
Message 2 of 7
(4,855 Views)


@Josv wrote:
Hello,

 

I have trouble to communicate with a USB device thought call library function. My cypress chip is installed to the ezusb.sys driver and is be able to communicate with the ezusbsys.h file. (Have communicated with my device thought a CIN but the program shown not stable enough)…

 I have read trough some parts of the “Using External Code in LabVIEW” which briefly describes how to act:

“Instructions on including a header file xbus.h. Although LabVIEW

does not permit you to include such header files, you can open header

files and extract information about function prototypes and constants.”

 

Nothing that I have tried with have worked and hopping now that someone else has worked with something similar.

Links, examples and tips are happily received.

 

 

Best regards,

Jonny



A *.sys file is a kernel device driver. LabVIEW can't directly link to a kernel device driver. You will need a so called user level DLL to talk to the kernel device driver. Such a user level DLL is usually provided by the developer of the kernel device driver as well.

I really doubt that the ezusbsys.h file is all that is needed for an application to call this device driver. Typically a device driver is accessed by a series of calls to the Windows kernel API functions CreateFile(), ReadFile(), WriteFile(), DevIOCtrl() and CloseHandle() and these are put into a so called user level DLL by the device driver developer for convinience of the user.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 7
(4,846 Views)

> You mentioned having made a CIN but that it's not "stable enough". Can you elaborate?

See a previous message that I posted:

http://forums.ni.com/ni/board/message?board.id=170&message.id=158491

 

 

>I really doubt that the ezusbsys.h file is all that is needed for an application to call this device driver.

From discussion with Cypress and with own programming on the CIN the ezusbsys.h is the only link towards the chip, unless you want to use there API.

 

Thanks for your opinions...

 

/Jonny

0 Kudos
Message 4 of 7
(4,832 Views)


@Josv wrote:

> You mentioned having made a CIN but that it's not "stable enough". Can you elaborate?

See a previous message that I posted:

http://forums.ni.com/ni/board/message?board.id=170&message.id=158491

 

 

>I really doubt that the ezusbsys.h file is all that is needed for an application to call this device driver.

From discussion with Cypress and with own programming on the CIN the ezusbsys.h is the only link towards the chip, unless you want to use there API.

 

Thanks for your opinions...

 

/Jonny



Well as you say yourself "unless you want to use their API". This API is most probably the user level DLL I was talking about and calling that with the Call Library Node is probably a lot easier than trying to figure out how to call the device driver directly.

As to the problems you have had with your CIN you obviously still made an error somewhere. Without the source code in question to review there is only wild guessing we can do as to where it might go wrong. That and pointing you to the links about what to watch out when interfacing external code in LabVIEW. But if you had a problem with the CIN I do not see how you think you can do better with trying to avoid the CIN, without using the API DLL from Cypress. The error you made in the CIN has a good chance to also appear in any other solution you come up with to interface to the device driver directly, and many more errors too.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 7
(4,826 Views)

Hai,

I am Pavan Ram Kumar Somu.

 

I am new to Labview, currently I am working on MVB Interface.

 

I need to access the API functions from *.dll file in Labview, as of now , I am doing this with Call function Library node in Labview but it does not support the following data types like

    1. Pointer Arguments(To which memory it points in Labview)

    2. function pointers Arguments

    3 .pointers in structures and pointer structures in structures and many other data types.

 

Please Answer the below queries also:

 

1. How to pass pointer arguments to API functions in DLL and how to collect pointer  

    return types from API functions in DLL

 

2. How to pass structure arguments to API functions in DLL and how to collect structure

    return types from API functions in DLL

 

3. How to use callback functions(nothing but function pointers) in Labview and how to

    collect callback fuctions return types from API functions in DLL

 

I need your help while passing these datatypes to API functions in DLL from labview.

 

Suggest me if there is any other alternative for implementing this task.

 

 

I am referencing some examples here:

Examples:

I)

Unsigned short int gf_open_device(void *p_device_config, unsigned long int client_life_sign_timeout, unsigned short int *device_error)

 

void *p_device_config: How to access/pass these arguments in LabView and to which memory location it points in LabView.

 

II) #include <windows.h>

     #include <process.h>

   

     HANDLE rcvEvent0, rcvEvent1;

 

/* Function call*/

CanGetReceiveEvent(handle[0], &rcvEvent0);

 

Above is a piece of C code, Now I want to use HANDLE datatype which is windows based, how to use these type in the LABVIEW.
0 Kudos
Message 6 of 7
(4,588 Views)

Hello Somu,

Were you able to get data from the void* () functions?

>3. How to use callback functions(nothing but function pointers) in Labview and how to

>    collect callback fuctions return types from API functions in DLL

 

Could you please attach if you have any example or solutions?

 

Thanks,

Omer

0 Kudos
Message 7 of 7
(4,207 Views)