Why can't FT_GetComPortNumber fetch my com port?

83 views Asked by At

I have a Digilent CMOD S7 FPGA I'm trying to communicate with that is equipped with an FT2232HQ for UART communication. I've installed VCP and D2XX drivers from the FTDI site and the device shows up as COM12 on device manager with the proper manufacturer name, but when running this code, I get "no com port installed".

Any clue what I'm doing wrong here?

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include "ftd2xx.h"

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;  
    
    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);
    

    return 0;
}
1

There are 1 answers

0
bowlcutty On BEST ANSWER

It seems as if FT_Open was automatically connecting to the wrong device.

My solution was to use FT_ListDevices to get the device description of my FPGA, and then use FT_OpenEx to open a specific device based on a given device description. Then, being connected to the proper device, I was able to get my COM port number with FT_GetComPortNumber.