I want to list all COM ports, which are virtual ports of FTDI controllers.
To accopolish that, I tried to use the methods GetDeviceList
and OpenBySerialNumber
, provided by the official .NET wrapper ("FTD2XX_NET") for the official FTDI library:
List<string> listResult = new List<string>();
FTD2XX.FT_DEVICE_INFO_NODE[] arrInfoNodes =
new FTD2XX.FT_DEVICE_INFO_NODE[intALotMoreThanExpectedInfoNodeCount];
FTD2XX fObject = createFtdiInstance();
foreach (FTD2XX.FT_DEVICE_INFO_NODE node in arrInfoNodes)
{
if (node == null)
{
break;
}
else
{
if (fObject.OpenBySerialNumber(node.SerialNumber) ==
Ftdi.FTD2XX.FT_STATUS.FT_OK)
{
fObject.GetCOMPort(out strPortName);
listResult.Add(strPortName);
}
}
}
My Problem with this is now: After the Iteration over all nodes, the ftdi devices have to be unpluged and reconnected until I can use them again (with any Software).