09-14-2005 12:37 PM
I am using a Cypress CY7C68013A USB chip to develop some hardware that will connect to a PC. I want to use LabView to send and receive data via this interface. The driver provided by Cypress for this IC is accessed via a statically compiled MS Visual C++ library called CyAPI.lib. I do not have access to the source code. I do have documentation on the API. I suspect that I will have to write a C wrapper for each object field/method. I would like to avoid this if possible. What are my options for getting LabView to access the CyAPI.lib?
Any help would be greatly appreciated!
09-15-2005 11:25 AM
Hi,
To quote Microsoft : "A static library is a file containing objects and their functions and data that is linked into your program when the executable file is built. This topic explains how to create the starter files and project settings for a static library. You can link a static library to an MFC-based program or to a non-MFC program for Windows written in C or C++, that makes calls to the Win32 API rather than to MFC classes. "
LabVIEW cannot directly link to a statically compiled .lib file but there is a workaround : Create a C or C++ DLL that links to this statically compiled .LIB file and call the DLL from LabVIEW. Since it is the C compiler that is linking to the .LIB file, LabVIEW does not know anyhing about the.LIB file but will just communicate indirectly with the .LIB via the C/C++ DLL.
Hope this helps,
Ankita
09-15-2005 11:46 AM
09-16-2005 05:23 PM
09-19-2005 11:16 AM
Hi Ankita,
Thank you for your assistance thus far, you have been a great help!
I do have one final issue to resolve. I have been warned by colleges that LabView does not work well with externally allocated memory. I am worried this would apply to objects created in a .dll. The documentation I have read does not seem to address this issue directly.
QUESTION: How should I create objects from my library .dll file that will safely exist after exiting a "Call Library Function" VI?
For example, I would like to create a USBdevice object at the start of my LabView application that would exist until the program is exited. I could then make calls to read/write methods as needed. Otherwise, I will have to create and destroy a USBdevice everytime I communicate with my hardware via the device driver. Constantly creating and destroying this object would be very inefficient.
Please advise.
-- Al Dugas
09-19-2005 03:02 PM