int main(int argc, char* argv[])
{
FT_HANDLE fthandle;
FT_STATUS res;
LONG COMPORT;
char COMx[5];
int n;
DCB dcb;
HANDLE hCommPort;
BOOL fSuccess;
/***********************************************************************
//Find the com port that has been assigned to your device.
/***********************************************************************/
res = FT_Open(0, &fthandle);
if(res != FT_OK){
printf("opening failed! with error %d\n", res);
return 1;
}
res = FT_GetComPortNumber(fthandle,&COMPORT);
if(res != FT_OK){
printf("get com port failed %d\n", res);
return 1;
}
if (COMPORT == -1){
printf("no com port installed \n");
}
else{
printf("com port number is %d\n", COMPORT);
}
FT_Close(fthandle);
/********************************************************/
// Open the com port assigned to your device
/********************************************************/
/********************************************************/
// Writing data to the USB to UART converter
/********************************************************/
/********************************************************/
//Reading data from the USB to UART converter
/********************************************************/
char buf[256];
DWORD dwRead;
memset(buf,0,256);
if (ReadFile(hCommPort, buf, w_data_len, &dwRead, NULL))
{
printf("data read = %s\n", buf);
}
/********************************************************/
//Closing the device at the end of the program
/********************************************************/