Your browser does not allow scripts
Please click here to view a static table of contents without scripts
FT_OpenEx
Return to Introduction  Previous page  Next page
Open the specified device and return a handle that will be used for subsequent accesses. The device can be specified by its serial number, device description or location.

This function can also be used to open multiple devices simultaneously. Multiple devices can be opened at the same time if they can be distinguished by serial number or device description. Alternatively, multiple devices can be opened at the same time using location IDs - location information derived from their physical locations on USB. Location IDs can be obtained using the utility USBView
and are given in hexadecimal format
.

FT_STATUS
FT_OpenEx
(PVOID pvArg1, DWORD dwFlags, FT_HANDLE *ftHandle)




Parameters
pvArg1
Meaning depends on dwFlags, but it will normally be interpreted as a pointer to a null terminated string.
dwFlags
FT_OPEN_BY_SERIAL_NUMBER, FT_OPEN_BY_DESCRIPTION or FT_OPEN_BY_LOCATION.
ftHandle
Pointer to a variable of type FT_HANDLE where the handle will be stored. This handle must be used to access the device.





Return Value
FT_OK if successful, otherwise the return value is an FT error code.



Remarks
The meaning of pvArg1 depends on dwFlags: if dwFlags is FT_OPEN_BY_SERIAL_NUMBER, pvArg1 is interpreted as a pointer to a null-terminated string that represents the serial number of the device; if dwFlags is FT_OPEN_BY_DESCRIPTION, pvArg1 is interpreted as a pointer to a null-terminated string that represents the device description; if dwFlags is FT_OPEN_BY_LOCATION, pvArg1 is interpreted as a long value that contains the location ID of the device. Please note that Windows CE and Linux do not support location IDs.

ftHandle is a pointer to a variable of type FT_HANDLE where the handle is to be stored. This handle must be used to access the device.



Examples
The examples that follow use these variables.

FT_STATUS ftStatus;
FT_STATUS ftStatus2;
FT_HANDLE ftHandle1;
FT_HANDLE ftHandle2;
long dwLoc;


Open a device with serial number "FT000001"

ftStatus = FT_OpenEx("FT000001",FT_OPEN_BY_SERIAL_NUMBER,&ftHandle1);
if (ftStatus == FT_OK) {
   // success - device with serial number "FT000001" is open
}
else {
   // failure
}


Open a device with device description "USB Serial Converter"

ftStatus = FT_OpenEx("USB Serial Converter",FT_OPEN_BY_DESCRIPTION,&ftHandle1);
if (ftStatus == FT_OK) {
   // success - device with device description "USB Serial Converter" is open
}
else {
   // failure
}

Open 2 devices with serial numbers "FT000001" and "FT999999"

ftStatus = FT_OpenEx("FT000001",FT_OPEN_BY_SERIAL_NUMBER,&ftHandle1);
ftStatus2 = FT_OpenEx("FT999999",FT_OPEN_BY_SERIAL_NUMBER,&ftHandle2);
if (ftStatus == FT_OK && ftStatus2 == FT_OK) {
   // success - both devices are open
}
else {
   // failure - one or both of the devices has not been opened
}


Open 2 devices with descriptions "USB Serial Converter" and "USB Pump Controller"

ftStatus = FT_OpenEx("USB Serial Converter",FT_OPEN_BY_DESCRIPTION,&ftHandle1);
ftStatus2 = FT_OpenEx("USB Pump Controller",FT_OPEN_BY_DESCRIPTION,&ftHandle2);
if (ftStatus == FT_OK && ftStatus2 == FT_OK) {
   // success - both devices are open
}
else {
   // failure - one or both of the devices has not been opened
}


Open a device at location 23

dwLoc = 0x23;
ftStatus = FT_OpenEx(dwLoc,FT_OPEN_BY_LOCATION,&ftHandle1);
if (ftStatus == FT_OK) {
   // success - device at location 23 is open
}
else {
   // failure
}


Open 2 devices at locations 23 and 31

dwLoc = 0x23;
ftStatus = FT_OpenEx(dwLoc,FT_OPEN_BY_LOCATION,&ftHandle1);
dwLoc = 0x31;
ftStatus2 = FT_OpenEx(dwLoc,FT_OPEN_BY_LOCATION,&ftHandle2);
if (ftStatus == FT_OK && ftStatus2 == FT_OK) {
   // success - both devices are open
}
else {
   // failure - one or both of the devices has not been opened
}