04-28-2011 10:01 AM - edited 04-28-2011 10:10 AM
I'm developping on LabWindows CVI.
I'd like to communicate with a chip FTDI by USB. the manufacturer provided a library ftd2xx.h to communicate with the chip in C. In using C programming without CVI, I successed to communicate with the chip, however, in adding my library in my CVI project and called it in the C program, It gives me a lot of error in the ftd2xx.h library.
Do I have to include other files to use a library provided by a manufacturer?
Thanks a lot.
Johan
Solved! Go to Solution.
04-28-2011 11:39 AM
With the FTDI library, you'll have to include windows.h before the ftd2xx.h header file, as the FTDI library depends on a lot of items that are declared in that header. Hopefully that will solve your errors.
04-28-2011 11:57 PM
Did you follow the hints for Labwindows/CVI ( in "Application Software") in the FTDI knowledgebase. ?
If that doesn't help, could you be more specific about the error messages, you are getting ?
Please post at least one error message literally.
04-29-2011 01:32 AM
Thank you very much for your fast answers.
I will try it immediately. I will come back to tell you if it works.
bye
04-29-2011 03:06 AM
It's ok, I used your solution, and I don't have error about ftd2xx.h anymore.
However, my program don't get FT_STATUS type and DWORD type. See in InitProg function.
I don't understant because these types are clearly defined in the ftd2xx.h.
If you wan help me again, it would be great.
Thanks
#include <cvirte.h>
#include <userint.h>
#include <windows.h>
#include "FirstProject.h"
#include "ftd2xx.h"
static int panelHandle;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "FirstProject.uir", Panel)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK QuitPROG (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
int CVICALLBACK InitPROG (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
FT_STATUS ftStatus;
DWORD numDevs;
char *BufPtrs[3];
char Buffer[16];
char Buffer1[64]; //Description du device 1 (portA)
char Buffer2[64]; //Description du device 2 (portB)
BufPtrs[0] = Buffer1;
BufPtrs[1] = Buffer2;
BufPtrs[2] = NULL;
ftStatus = FT_ListDevices(BufPtrs, &numDevs, FT_LIST_ALL|FT_OPEN_BY_DESCRIPTION);
break;
}
return 0;
}
Errors:
39, 13 Illegal use of type name 'FT_STATUS'.
39, 23 syntax error; found 'identifier' expecting ';'.
39, 23 Undeclared identifier 'ftStatus'.
04-29-2011 04:32 AM
I found my mistake.
We cannot declare variables in case function. I put them out of the switch and it's OK now.
11-17-2017 10:13 AM
I have the same issue but i'm using CVI 2012 and it doesn't have the "Compatability with: Visual C/C++" option under build options. Would you know what i have to set for CVI 2012 to use FTDI header.
11-20-2017 08:44 AM
That option was removed because the other choice "Compatibility with Borland C/C++" was removed . Now Labwindows/CVI is always compatible with Visual C++.