FT_GetDeviceInfo函数的用法

介绍FT_GetDeviceInfo函数的用法、参数、返回值、注意事项、适用的操作系统环境、调用代码示例等。

null

支持的操作系统

Linux

Mac OS X 10.4 以上版本

Windows 2000 以上版本

Windows CE 4.2以上版本

概述

FT_GetDeviceInfo函数获取一个已经打开的设备的信息。

定义

FT_STATUS FT_GetDeviceInfo (FT_HANDLE ftHandle, FT_DEVICE *pftType, LPDWORD lpdwID, PCHAR pcSerialNumber,PCHAR pcDescription, PVOID pvDummy)

参数说明

ftHandle—设备句柄。

pftType—指向unsigned long类型变量地址的指针,该变量 存储设备类型。

lpdwID—指向unsigned long类型变量地址的指针,该变量 存储设备编号。

pcSerialNumber—字符数组指针,字符数组存储设备序列号serial number。

pcDescription —字符数组指针,字符数组存储设备描述符。

pvDummy —备用,设置为NULL。

返回值

成功则返回FT_OK,如果失败则根据错误返回特定错误码(FT_*).

备注

FT_GetDeviceInfo函数获取打开设备的设备类型(device type), 设备编号(device ID), 设备描述符(device description) 以及 设备序列号(serial number)。

设备编号(device ID)为DWORD类型 – 高位两字节为供货商ID, 低位两字节为产品编号(product ID);如:获取到 ID 为0x04036001 代表device ID=VID_0403&PID_6001。

代码示例

FT_HANDLE ftHandle;
FT_DEVICE ftDevice;
FT_STATUS ftStatus;
DWORD deviceID;
char SerialNumber[16];
char Description[64];
ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) {
// FT_Open failed
return;
}
ftStatus = FT_GetDeviceInfo(
ftHandle,
&ftDevice,
&deviceID,
SerialNumber,
Description,
NULL
);
if (ftStatus == FT_OK) {
if (ftDevice == FT_DEVICE_232H)
; // device is FT232H
else if (ftDevice == FT_DEVICE_4232H)
; // device is FT4232H
else if (ftDevice == FT_DEVICE_2232H)
; // device is FT2232H
else if (ftDevice == FT_DEVICE_232R)
; // device is FT232R
else if (ftDevice == FT_DEVICE_2232C)
; // device is FT2232C/L/D
else if (ftDevice == FT_DEVICE_BM)
; // device is FTU232BM
else if (ftDevice == FT_DEVICE_AM)
; // device is FT8U232AM
else
; // unknown device (this should not happen!)
// deviceID contains encoded device ID
// SerialNumber, Description contain 0-terminated strings
}
else {
// FT_GetDeviceType FAILED!
}
FT_Close(ftHandle);

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

昵称

取消
昵称表情代码图片

    暂无评论内容