FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: FT232H handle in visual studio  (Read 439 times)

Rajesh@sys

  • Newbie
  • *
  • Posts: 21
    • View Profile
FT232H handle in visual studio
« 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
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 335
    • View Profile
Re: FT232H handle in visual studio
« Reply #1 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 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 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
Logged

Rajesh@sys

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: FT232H handle in visual studio
« Reply #2 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
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 335
    • View Profile
Re: FT232H handle in visual studio
« Reply #3 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.

Best Regards,
FTDI Community
Logged