FTDI Community

General Category => Discussion - Hardware => Topic started by: Rajesh@sys on June 25, 2019, 11:16:53 AM

Title: FT232H handle in visual studio
Post by: Rajesh@sys on June 25, 2019, 11:16:53 AM
Hi,

 i am using visual studio 2017 to configure FT232H to synchronous mode.
i am able to detect ft232h as comport.(using vcp drivers)

as given pdf (building application  in visual studio) i have included .dll files from and header file  "d2xx driver".

i have used code from "TN_167 FIFO Basics (USB2.0)" fifo synchronous read code.


with these i am able  confirm FTDI IC is connected. as it showing(command prompt) code is excited with 0.

if i disconnect usb i am able to see "device status not ok".



my query is :

1) why i am not able to access ft_handle function.

2) code is everytime entering into null.


please suggest me., how access ft_handle



thanks
Title: Re: FT232H handle in visual studio
Post by: FTDI Community on June 26, 2019, 04:38:24 PM
Hello Rajesh,

Please see TN_153 Instructions on Including the D2XX Driver in a Visual Studio Express 2013 Project (https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_153%20Instructions%20on%20Including%20the%20D2XX%20Driver%20in%20a%20VS%20Express%202013%20Project.pdf) for more information.

Code: [Select]
ft_handle is used as follows:

FT_HANDLE fthandle;
FT_STATUS status;

status = FT_Open(0, &fthandle);

The status should be checked for errors. Error codes can be found in ftd2xx.h. FT_OK is 0.

This code snippet is opening the first FTDI device connected to the PC. You may want to make the code more robust by opening by serial number or description, for example:

Code: [Select]
status = FT_OpenEx("FTEE5MM", FT_OPEN_BY_SERIAL_NUMBER, &fthandle);
or

Code: [Select]
status = FT_OpenEx("FT232H", FT_OPEN_BY_DESCRIPTION, &fthandle);
All devices can be listed first using FT_CreateDeviceInfoList and FT_GetDeviceInfoList first. See the D2XX Programmer's Guide (https://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer's_Guide(FT_000071).pdf) for more information.

If the device is not connected, the function status will return an error code.

TN_167 code could be improved to exit the code when there are errors:

Code: [Select]
if(status != FT_OK)
{
printf("open device status not ok %d\n", status);
return 0;
}

Sometimes brackets are not used meaning that the code will continue:

Code: [Select]
if(status != FT_OK)
printf("timeout A status not ok %d\n", status);

Best Regards,
FTDI Community
Title: Re: FT232H handle in visual studio
Post by: Rajesh@sys on June 27, 2019, 08:15:34 AM
Hi,
   I have a doubt that the procedure which you mentioned in previous reply is similar for visual studio 2017 as I am using this IDE.
waiting for someone to help.

Regards,
Rajesh
Title: Re: FT232H handle in visual studio
Post by: FTDI Community on June 27, 2019, 02:19:45 PM
Hello Rajesh,

The procedure in my previous post is for C Programming in Visual Studio IDE.

Please refer to TN_153 Instructions on Including the D2XX Driver in a Visual Studio Express 2013 Project (https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_153%20Instructions%20on%20Including%20the%20D2XX%20Driver%20in%20a%20VS%20Express%202013%20Project.pdf).

Best Regards,
FTDI Community