LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a manufacturer C library

Solved!
Go to solution

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

0 Kudos
Message 1 of 8
(3,788 Views)

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.

0 Kudos
Message 2 of 8
(3,779 Views)
Solution
Accepted by topic author Johandball

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.

0 Kudos
Message 3 of 8
(3,766 Views)

Thank you very much for your fast answers.

 

I will try it immediately. I will come back to tell you if it works.

 

bye

0 Kudos
Message 4 of 8
(3,763 Views)

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'.

0 Kudos
Message 5 of 8
(3,756 Views)

I found my mistake.

 

We cannot declare variables in case function. I put them out of the switch and it's OK now.

0 Kudos
Message 6 of 8
(3,751 Views)

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.

0 Kudos
Message 7 of 8
(2,927 Views)

That option was removed because the other choice "Compatibility with Borland C/C++" was removed . Now Labwindows/CVI is always compatible with Visual C++.

0 Kudos
Message 8 of 8
(2,897 Views)