FT_OpenEx

Supported Operating Systems of FT_OpenEx

Linux
Mac OS X (10.4 and later)
Windows (2000 and later)
Windows CE (4.2 and later)

null

Summary of FT_OpenEx

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 specified
by serial number, device description or location ID (location information derived from the physical
location of a device on USB). Location IDs for specific USB ports can be obtained using the utility
USBView and are given in hexadecimal format. Location IDs for devices connected to a system can be
obtained by calling FT_GetDeviceInfoList or FT_ListDevices with the appropriate flags.
Definition of FT_OpenEx
FT_STATUS FT_OpenEx (PVOID pvArg1, DWORD dwFlags, FT_HANDLE *ftHandle)

Parameters of FT_OpenEx

pvArg1        Pointer to an argument whose type depends on the value of
dwFlags. It is 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 of FT_OpenEx

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

Remarks about FT_OpenEx

The parameter specified in 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 of FT_OpenEx

The examples that follow use these variables.
FT_STATUS ftStatus;
FT_STATUS ftStatus2;
FT_HANDLE ftHandle1;
FT_HANDLE ftHandle2;
long dwLoc;
1. 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
}
2. 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
}
3. 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
}
4. 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
}

5. 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
}
6. 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
}

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容