1
Discussion - Software / Using FT232R with Windows UWP
« on: May 16, 2019, 11:36:54 AM »
I am working on a Windows PC based application and having some issues. I have a RS485 cable from FTDI based on the FT232 IC.
In my UWP applications (written in VS 2017) I have the following:
// Create new instance of the FTDI device class
FTDI myFtdiDevice = new FTDI();
// Determine the number of FTDI devices connected to the machine
FTDI_Status = myFtdiDevice.GetNumberOfDevices(ref ftdiDeviceCount);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
//Check of FTDI cables worked OK
TxtDisplayTopRow.Text = "FTDI cable check OK";
TxtDisplayBottomRow.Text = ftdiDeviceCount + " connected";
// Allocate storage for device info list
FTDI.FT_DEVICE_INFO_NODE[] ftdiDeviceList = new FTDI.FT_DEVICE_INFO_NODE[ftdiDeviceCount];
// Populate our device list
FTDI_Status = myFtdiDevice.GetDeviceList(ftdiDeviceList);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
// Open first device in our list by serial number
FTDI_Status = myFtdiDevice.OpenBySerialNumber(ftdiDeviceList[0].SerialNumber);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
// Set up device data parameters
// Set Baud rate to 9600
FTDI_Status = myFtdiDevice.SetBaudRate(9600);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
// Set data characteristics - Data bits, Stop bits, Parity
FTDI_Status = myFtdiDevice.SetDataCharacteristics(FTDI.FT_DATA_BITS.FT_BITS_8, FTDI.FT_STOP_BITS.FT_STOP_BITS_1, FTDI.FT_PARITY.FT_PARITY_NONE);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
TxtDisplayTopRow.Text = "FTDI cable setup";
}
}
}
}
}
else
{
//FTDI check failed
}
Everything works great until I get to 'GetDeviceList(ftdiDeviceList);', this does return a list of connected devices but all the important properties are blank
I have added the following capabilities to the manifest
<DeviceCapability Name="usb">
<!--FT232AM, FT232BM, FT232R and FT245R Devices-->
<Device Id="vidpid:0403 6001">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT2232D and FT2232H Devices-->
<Device Id="vidpid:0403 6010">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT4232H Device-->
<Device Id="vidpid:0403 6011">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT232H Device-->
<Device Id="vidpid:0403 6014">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT-X-Series Devices-->
<Device Id="vidpid:0403 6015">
<Function Type="name:vendorSpecific" />
</Device>
<!--My Custom Device-->
<!--<Device Id="vidpid:1234 4321">
<Function Type="name:vendorSpecific" />
</Device>-->
</DeviceCapability>
The version of FTD2XX_NET is: 1.1.0.0
It would be good to know if anyone has successfully used the FTDI cables with UWP and if so what I need to do?
Many thanks
In my UWP applications (written in VS 2017) I have the following:
// Create new instance of the FTDI device class
FTDI myFtdiDevice = new FTDI();
// Determine the number of FTDI devices connected to the machine
FTDI_Status = myFtdiDevice.GetNumberOfDevices(ref ftdiDeviceCount);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
//Check of FTDI cables worked OK
TxtDisplayTopRow.Text = "FTDI cable check OK";
TxtDisplayBottomRow.Text = ftdiDeviceCount + " connected";
// Allocate storage for device info list
FTDI.FT_DEVICE_INFO_NODE[] ftdiDeviceList = new FTDI.FT_DEVICE_INFO_NODE[ftdiDeviceCount];
// Populate our device list
FTDI_Status = myFtdiDevice.GetDeviceList(ftdiDeviceList);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
// Open first device in our list by serial number
FTDI_Status = myFtdiDevice.OpenBySerialNumber(ftdiDeviceList[0].SerialNumber);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
// Set up device data parameters
// Set Baud rate to 9600
FTDI_Status = myFtdiDevice.SetBaudRate(9600);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
// Set data characteristics - Data bits, Stop bits, Parity
FTDI_Status = myFtdiDevice.SetDataCharacteristics(FTDI.FT_DATA_BITS.FT_BITS_8, FTDI.FT_STOP_BITS.FT_STOP_BITS_1, FTDI.FT_PARITY.FT_PARITY_NONE);
if (FTDI_Status == FTDI.FT_STATUS.FT_OK)
{
TxtDisplayTopRow.Text = "FTDI cable setup";
}
}
}
}
}
else
{
//FTDI check failed
}
Everything works great until I get to 'GetDeviceList(ftdiDeviceList);', this does return a list of connected devices but all the important properties are blank
I have added the following capabilities to the manifest
<DeviceCapability Name="usb">
<!--FT232AM, FT232BM, FT232R and FT245R Devices-->
<Device Id="vidpid:0403 6001">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT2232D and FT2232H Devices-->
<Device Id="vidpid:0403 6010">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT4232H Device-->
<Device Id="vidpid:0403 6011">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT232H Device-->
<Device Id="vidpid:0403 6014">
<Function Type="name:vendorSpecific" />
</Device>
<!--FT-X-Series Devices-->
<Device Id="vidpid:0403 6015">
<Function Type="name:vendorSpecific" />
</Device>
<!--My Custom Device-->
<!--<Device Id="vidpid:1234 4321">
<Function Type="name:vendorSpecific" />
</Device>-->
</DeviceCapability>
The version of FTD2XX_NET is: 1.1.0.0
It would be good to know if anyone has successfully used the FTDI cables with UWP and if so what I need to do?
Many thanks