遍历 USB devcie,读取设备描述符 device descriptor【转】

转自:http://blog.csdn.net/flyyyri/article/details/5480347

理论:
    对于USB接口的设备,现在越来越多了。本篇我们就通过获取一个USB扫描仪设备中的序列号,来介绍如何获取usb设备的一些硬件信息。对于usb设备都是采用HCD0,HCD1,HCD2,HCD3等符号描述的。如下图:

因此,有了这个名字,我们就可以使用CreateFile来打开usb设备。然后使用DeviceIoControl函数与usb设备通讯了。HCD是host controller driver的简写。需要了解详情的,还要仔细的阅读usb协议。
usb的通讯基本步骤如下图所示:

基本步骤:
    1)打开HCD%X
    2) 得到上面的USB root hub
    3) 遍历usb root hub上连接的usb 设备。获取信息
    4)如果有多个usb口,循环前3步。

下面介绍通讯用的几个IOCTL:
1)USB_HCD_DRIVERKEY_NAME ,用于获取USB设备驱动在注册表中的键名。相应的一个结构体是:
typedef struct _USB_HCD_DRIVERKEY_NAME 
{
   ULONG   ActualLength;
   WCHAR   DriverKeyName[1];
} USB_HCD_DRIVERKEY_NAME, *PUSB_HCD_DRIVERKEY_NAME;

2)IOCTL_USB_GET_ROOT_HUB_NAME,用于获取root hub 键名。使用的结构体,跟上面一样。
typedef struct _USB_ROOT_HUB_NAME 
{
    ULONG ActualLength; 
    WCHAR RootHubName[1]; 
} USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;

3)IOCTL_USB_GET_NODE_INFORMATION,用于获取连接在root hub上的节点设备信息。也就是我们接在usb口上的所有usb设备的信息,对应的结构体:
typedef struct _USB_NODE_INFORMATION 
{
    USB_HUB_NODE NodeType;    
    union {
        USB_HUB_INFORMATION HubInformation;
        USB_MI_PARENT_INFORMATION MiParentInformation;
    } u;
} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;

typedef struct _USB_MI_PARENT_INFORMATION 
{
    ULONG NumberOfInterfaces;
} USB_MI_PARENT_INFORMATION, *PUSB_MI_PARENT_INFORMATION;

typedef struct _USB_HUB_INFORMATION
{
    USB_HUB_DESCRIPTOR HubDescriptor;

BOOLEAN HubIsBusPowered;

} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;

typedef struct _USB_HUB_DESCRIPTOR
{
    UCHAR        bDescriptorLength;      // Length of this descriptor
    UCHAR        bDescriptorType;        // Hub configuration type
    UCHAR        bNumberOfPorts;         // number of ports on this hub
    USHORT       wHubCharacteristics;    // Hub Charateristics
    UCHAR        bPowerOnToPowerGood;    // port power on till power good in 2ms
    UCHAR        bHubControlCurrent;     // max current in mA
    //
    // room for 255 ports power control and removable bitmask
    UCHAR        bRemoveAndPowerMask[64];       
} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;

4) IOCTL_USB_GET_NODE_CONNECTION_INFORMATION, 用于获取接在usb口上的单个usb设备的信息,对应的结构体:

typedef struct _USB_NODE_CONNECTION_INFORMATION 
{
    ULONG ConnectionIndex;
    USB_DEVICE_DESCRIPTOR DeviceDescriptor;
    UCHAR CurrentConfigurationValue;
    BOOLEAN LowSpeed;

BOOLEAN DeviceIsHub;

USHORT DeviceAddress;

ULONG NumberOfOpenPipes;

USB_CONNECTION_STATUS ConnectionStatus;
    USB_PIPE_INFO PipeList[0];
} USB_NODE_CONNECTION_INFORMATION, *PUSB_NODE_CONNECTION_INFORMATION;

4)IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, 用于获取usb设备的描述信息。
typedef struct _USB_DEVICE_DESCRIPTOR 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    USHORT bcdUSB;
    UCHAR bDeviceClass;
    UCHAR bDeviceSubClass;
    UCHAR bDeviceProtocol;
    UCHAR bMaxPacketSize0;
    USHORT idVendor;
    USHORT idProduct;
    USHORT bcdDevice;
    UCHAR iManufacturer;
    UCHAR iProduct;
    UCHAR iSerialNumber;
    UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;

typedef struct _USB_DEVICE_DESCRIPTOR 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    USHORT bcdUSB;
    UCHAR bDeviceClass;
    UCHAR bDeviceSubClass;
    UCHAR bDeviceProtocol;
    UCHAR bMaxPacketSize0;
    USHORT idVendor;
    USHORT idProduct;
    USHORT bcdDevice;
    UCHAR iManufacturer;
    UCHAR iProduct;
    UCHAR iSerialNumber;
    UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;

typedef enum _USB_CONNECTION_STATUS 
{
    NoDeviceConnected,
    DeviceConnected,

/* failure codes, these map to fail reasons */
    DeviceFailedEnumeration,
    DeviceGeneralFailure,
    DeviceCausedOvercurrent,
    DeviceNotEnoughPower,
    DeviceNotEnoughBandwidth,
    DeviceHubNestedTooDeeply,
    DeviceInLegacyHub
} USB_CONNECTION_STATUS, *PUSB_CONNECTION_STATUS;

typedef struct _USB_PIPE_INFO
{
    USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    ULONG ScheduleOffset;
} USB_PIPE_INFO, *PUSB_PIPE_INFO;

typedef struct _USB_ENDPOINT_DESCRIPTOR
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bEndpointAddress;
    UCHAR bmAttributes;
    USHORT wMaxPacketSize;
    UCHAR bInterval;
} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;

需要注意一点,如果要得到pid,vid,则直接从USB_DEVICE_DESCRIPTOR结构中取出idVendor,idProduct这两项的值就行了。如果要得到序列号,则不是取出 iSerialNumber就可以的。这里的 iSerialNumber仅仅是一个索引值。如果想得到序列号,就需要定义一个结构,然后给设备发送个请求。请求的结构如下图:

代码参照GetStringDescriptor函数。可以根据iSerialNumber偏移,取出其对应的字符串,存放在上图USB_STRING_DESCRIPTOR结构中。
#include "windows.h"
#include "PlkUsbIo.h"
#include <malloc.h>

#define NUM_HCS_TO_CHECK 10

/******************************************************************/
bool EnumUsbDevice();
PCHAR GetDriverKeyName(HANDLE Hub, ULONG ConnectionIndex);
PCHAR GetHCDDriverKeyName(HANDLE HCD);
PCHAR GetRootHubName(HANDLE HostController);
PCHAR WideStrToMultiStr(PWCHAR WideStr);
bool GetStringDescriptor (
        HANDLE hHubDevice,
        ULONG   ConnectionIndex,
        UCHAR   DescriptorIndex    ,
        CHAR * outBuff);
    
/******************************************************************/

int main(int argc, char* argv[])
{
    EnumUsbDevice();
    return 0;
}

bool EnumUsbDevice()
{
    char        HCName[16];
    int         HCNum;
    HANDLE      hHCDev;
    PCHAR       rootHubName;

ULONG       index;
    BOOL        success;

PUSB_NODE_CONNECTION_INFORMATION    connectionInfo;
    HANDLE hHubDevice;

for (HCNum = 0; HCNum < NUM_HCS_TO_CHECK; HCNum++)
    {
        wsprintf(HCName, "////.//HCD%d", HCNum);
        hHCDev = CreateFile(HCName,
            GENERIC_WRITE,
            FILE_SHARE_WRITE,
            NULL,
            OPEN_EXISTING,
            0,
            NULL);
        if (hHCDev == INVALID_HANDLE_VALUE)    
            break;
        
        PCHAR driverKeyName, deviceDesc;
        driverKeyName = GetHCDDriverKeyName(hHCDev);
        if(driverKeyName == NULL)
            goto end;    
        
    
        ULONG nBytes;
        rootHubName =(char*) GetRootHubName(hHCDev);
        if(rootHubName==NULL)
            goto end;
    
        PUSB_NODE_INFORMATION HubInfo;
        HubInfo = (PUSB_NODE_INFORMATION)malloc(sizeof(USB_NODE_INFORMATION));
        PCHAR deviceName;
        deviceName = (PCHAR)malloc(strlen(rootHubName) + sizeof("////.//"));
        if (rootHubName != NULL)
        {
            strcpy(deviceName, "////.//");
            strcpy(deviceName + sizeof("////.//") - 1, rootHubName);
            hHubDevice = CreateFile(deviceName,
                GENERIC_WRITE,
                FILE_SHARE_WRITE,
                NULL,
                OPEN_EXISTING,
                0,
                NULL);
            free(deviceName);
            if (hHubDevice == INVALID_HANDLE_VALUE)
                goto end;
            
            success = DeviceIoControl(hHubDevice,
                IOCTL_USB_GET_NODE_INFORMATION,
                HubInfo,
                sizeof(USB_NODE_INFORMATION),
                HubInfo,
                sizeof(USB_NODE_INFORMATION),
                &nBytes,
                NULL);
            if (!success)
                goto end;

}

int port;
        port=HubInfo->u.HubInformation.HubDescriptor.bNumberOfPorts;
        for (index=1; index <= port; index++)
        {
            ULONG nBytes;
            nBytes = sizeof(USB_NODE_CONNECTION_INFORMATION) +
                sizeof(USB_PIPE_INFO) * 30;
            connectionInfo = (PUSB_NODE_CONNECTION_INFORMATION)malloc(nBytes);
            if (connectionInfo == NULL)
                goto end;
            
            connectionInfo->ConnectionIndex = index;
            success = DeviceIoControl(hHubDevice,
                IOCTL_USB_GET_NODE_CONNECTION_INFORMATION,
                connectionInfo,
                nBytes,
                connectionInfo,
                nBytes,
                &nBytes,
                NULL);
            if (!success)
            {
                free(connectionInfo);
                goto end;
            }

deviceDesc = NULL;
            if (connectionInfo->ConnectionStatus != NoDeviceConnected)
            {
                driverKeyName = GetDriverKeyName(hHubDevice,
                    index);
                if (driverKeyName)
                {
                    free(driverKeyName);
                }
            }

if (connectionInfo->ConnectionStatus == DeviceConnected)
            {
                //取出序列号索引
                UCHAR nSerialno = connectionInfo->DeviceDescriptor.iSerialNumber;
                CHAR OutBuff[20] = {0};
                GetStringDescriptor(hHubDevice,connectionInfo->ConnectionIndex,nSerialno,OutBuff);

//判断序列号是否有效
                if(序列号是否有效)
                {
                      CloseHandle(hHubDevice);
                      CloseHandle(hHCDev);
                     return true;
                }
            }

}
end:; 
    }

CloseHandle(hHubDevice);
    CloseHandle(hHCDev);
    return false;
}

PCHAR GetDriverKeyName(HANDLE Hub, ULONG ConnectionIndex)
{
    BOOL                                success;
    ULONG                               nBytes;
    USB_NODE_CONNECTION_DRIVERKEY_NAME driverKeyName;
    PUSB_NODE_CONNECTION_DRIVERKEY_NAME driverKeyNameW;
    PCHAR                               driverKeyNameA;

driverKeyNameW = NULL;
    driverKeyNameA = NULL;

driverKeyName.ConnectionIndex = ConnectionIndex;

success = DeviceIoControl(Hub,
        IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME,
        &driverKeyName,
        sizeof(driverKeyName),
        &driverKeyName,
        sizeof(driverKeyName),
        &nBytes,
        NULL);

if (!success)
    {
        goto GetDriverKeyNameError;
    }

nBytes = driverKeyName.ActualLength;

if (nBytes <= sizeof(driverKeyName))
    {
        goto GetDriverKeyNameError;
    }

driverKeyNameW = (PUSB_NODE_CONNECTION_DRIVERKEY_NAME)malloc(nBytes);

if (driverKeyNameW == NULL)
    {
        goto GetDriverKeyNameError;
    }

driverKeyNameW->ConnectionIndex = ConnectionIndex;

success = DeviceIoControl(Hub,
        IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME,
        driverKeyNameW,
        nBytes,
        driverKeyNameW,
        nBytes,
        &nBytes,
        NULL);

if (!success)
    {
        goto GetDriverKeyNameError;
    }
    driverKeyNameA = WideStrToMultiStr(driverKeyNameW->DriverKeyName);
    free(driverKeyNameW);

return driverKeyNameA;

GetDriverKeyNameError:
    if (driverKeyNameW != NULL)
    {
        free(driverKeyNameW);
        driverKeyNameW = NULL;
    }

return NULL;
}
PCHAR GetRootHubName(HANDLE HostController)
{
    BOOL                success;
    ULONG               nBytes;
    USB_ROOT_HUB_NAME   rootHubName;
    PUSB_ROOT_HUB_NAME rootHubNameW;
    PCHAR               rootHubNameA;

rootHubNameW = NULL;
    rootHubNameA = NULL;

success = DeviceIoControl(HostController,
        IOCTL_USB_GET_ROOT_HUB_NAME,
        0,
        0,
        &rootHubName,
        sizeof(rootHubName),
        &nBytes,
        NULL);

if (!success)
    {
        goto GetRootHubNameError;
    }

nBytes = rootHubName.ActualLength;

rootHubNameW =(PUSB_ROOT_HUB_NAME) malloc(nBytes);

if (rootHubNameW == NULL)
    {

goto GetRootHubNameError;
    }

success = DeviceIoControl(HostController,
        IOCTL_USB_GET_ROOT_HUB_NAME,
        NULL,
        0,
        rootHubNameW,
        nBytes,
        &nBytes,
        NULL);

if (!success)
    {
        goto GetRootHubNameError;
    }

rootHubNameA = WideStrToMultiStr(rootHubNameW->RootHubName);
    free(rootHubNameW);

return rootHubNameA;

GetRootHubNameError:
    if (rootHubNameW != NULL)
    {
        free(rootHubNameW);
        rootHubNameW = NULL;
    }

return NULL;
}
PCHAR GetHCDDriverKeyName(HANDLE HCD)
{
    BOOL                    success;
    ULONG                   nBytes;
    USB_HCD_DRIVERKEY_NAME driverKeyName;
    PUSB_HCD_DRIVERKEY_NAME driverKeyNameW;
    PCHAR                   driverKeyNameA;

driverKeyNameW = NULL;
    driverKeyNameA = NULL;

success = DeviceIoControl(HCD,
        IOCTL_GET_HCD_DRIVERKEY_NAME,
        &driverKeyName,
        sizeof(driverKeyName),
        &driverKeyName,
        sizeof(driverKeyName),
        &nBytes,
        NULL);

if (!success)
    {
        goto GetHCDDriverKeyNameError;
    }

nBytes = driverKeyName.ActualLength;

if (nBytes <= sizeof(driverKeyName))
    {
        goto GetHCDDriverKeyNameError;
    }

driverKeyNameW =(PUSB_HCD_DRIVERKEY_NAME) malloc(nBytes);

if (driverKeyNameW == NULL)
    {
        goto GetHCDDriverKeyNameError;
    }

success = DeviceIoControl(HCD,
        IOCTL_GET_HCD_DRIVERKEY_NAME,
        driverKeyNameW,
        nBytes,
        driverKeyNameW,
        nBytes,
        &nBytes,
        NULL);

if (!success)
    {
        goto GetHCDDriverKeyNameError;
    }

driverKeyNameA = WideStrToMultiStr(driverKeyNameW->DriverKeyName);
    free(driverKeyNameW);

return driverKeyNameA;

GetHCDDriverKeyNameError:
    if (driverKeyNameW != NULL)
    {
        free(driverKeyNameW);
        driverKeyNameW = NULL;
    }

return NULL;
}

PCHAR WideStrToMultiStr(PWCHAR WideStr)
{
    ULONG nBytes;
    PCHAR MultiStr;
    nBytes = WideCharToMultiByte(
        CP_ACP,
        0,
        WideStr,
        -1,
        NULL,
        0,
        NULL,
        NULL);

if (nBytes == 0)
    {
        return NULL;
    }
    MultiStr =(PCHAR) malloc(nBytes);

if (MultiStr == NULL)
    {
        return NULL;
    }
    nBytes = WideCharToMultiByte(
        CP_ACP,
        0,
        WideStr,
        -1,
        MultiStr,
        nBytes,
        NULL,
        NULL);

if (nBytes == 0)
    {
        free(MultiStr);
        return NULL;
    }

return MultiStr;
}

bool    GetStringDescriptor (
        HANDLE hHubDevice,
        ULONG   ConnectionIndex,
        UCHAR   DescriptorIndex    ,
        CHAR * outBuff
        )
    {
        BOOL    success;
        ULONG   nBytes;
        ULONG   nBytesReturned;

UCHAR   stringDescReqBuf[sizeof(USB_DESCRIPTOR_REQUEST) + MAXIMUM_USB_STRING_LENGTH];

PUSB_DESCRIPTOR_REQUEST stringDescReq;
        PUSB_STRING_DESCRIPTOR stringDesc;

nBytes = sizeof(stringDescReqBuf);

stringDescReq = (PUSB_DESCRIPTOR_REQUEST)stringDescReqBuf;
        stringDesc = (PUSB_STRING_DESCRIPTOR)(stringDescReq+1);

::ZeroMemory(stringDescReq,nBytes);
        stringDescReq->ConnectionIndex = ConnectionIndex;
        stringDescReq->SetupPacket.wValue = (USB_STRING_DESCRIPTOR_TYPE << 8) | DescriptorIndex;
        stringDescReq->SetupPacket.wIndex = GetSystemDefaultLangID();
        stringDescReq->SetupPacket.wLength = (USHORT)(nBytes - sizeof(USB_DESCRIPTOR_REQUEST));

success = DeviceIoControl(hHubDevice,IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION,
                                stringDescReq,nBytes,
                                stringDescReq,nBytes,
                                &nBytesReturned,NULL);

if (!success || nBytesReturned < 2)
            return false;

if (stringDesc->bDescriptorType != USB_STRING_DESCRIPTOR_TYPE)
            return false;

if (stringDesc->bLength != nBytesReturned - sizeof(USB_DESCRIPTOR_REQUEST))
            return false;

if (stringDesc->bLength % 2 != 0)
            return false;

WCHAR * wChar = new WCHAR[stringDesc->bLength + 1];
        memcpy(wChar,stringDesc->bString,stringDesc->bLength);
        char *szTemp = WideStrToMultiStr(wChar);
        lstrcpy(outBuff, szTemp);
        
        if(szTemp)
        delete []szTemp;
        
        if(wChar)
        delete []wChar;
        return true;
    }

分析:

1)首先假定有10个usb接口
    #define NUM_HCS_TO_CHECK 10

2)循环打开这10个usb端口,如果端口没有这么多,调用CreateFile,就会返回 INVALID_HANDLE_VALUE。
    for (HCNum = 0; HCNum < NUM_HCS_TO_CHECK; HCNum++)
    {
        wsprintf(HCName, "////.//HCD%d", HCNum);
        hHCDev = CreateFile(HCName,
            GENERIC_WRITE,
            FILE_SHARE_WRITE,
            NULL,
            OPEN_EXISTING,
            0,
            NULL);
        if (hHCDev == INVALID_HANDLE_VALUE)    
            break;

3)获取root hub
       ULONG nBytes;
        rootHubName =(char*) GetRootHubName(hHCDev);
        if(rootHubName==NULL)
            goto end;

4) 遍历连接在root hub上的节点
        int port;
        port=HubInfo->u.HubInformation.HubDescriptor.bNumberOfPorts;
        for (index=1; index <= port; index++)
        {
            ULONG nBytes;
            nBytes = sizeof(USB_NODE_CONNECTION_INFORMATION) +
                sizeof(USB_PIPE_INFO) * 30;
            connectionInfo = (PUSB_NODE_CONNECTION_INFORMATION)malloc(nBytes);
            if (connectionInfo == NULL)
                goto end;
            
            connectionInfo->ConnectionIndex = index;
            success = DeviceIoControl(hHubDevice,
                IOCTL_USB_GET_NODE_CONNECTION_INFORMATION,
                connectionInfo,
                nBytes,
                connectionInfo,
                nBytes,
                &nBytes,
                NULL);
            if (!success)
            {
                free(connectionInfo);
                goto end;
            }

5)根据节点的连接状态,获取节点信息,得到序列号。
    if (connectionInfo->ConnectionStatus == DeviceConnected)
            {
                //取出序列号索引
                UCHAR nSerialno = connectionInfo->DeviceDescriptor.iSerialNumber;
                CHAR OutBuff[20] = {0};
                GetStringDescriptor(hHubDevice,connectionInfo->ConnectionIndex,nSerialno,OutBuff);

6)得到序列号的方法在理论部分已经详细说明了,对应的函数是GetStringDescriptor,这里不再重复。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jtujtujtu/archive/2009/11/19/4836900.aspx

时间: 2024-10-13 20:34:45

遍历 USB devcie,读取设备描述符 device descriptor【转】的相关文章

usb协议分析-设备描述符配置包-描述符

/* usb协议分析仅供大家参考---设备描述符配置包,设备描述符, 地址设置, 配置描述符, 字符串描述符 */ /* -1- usb设备描述符配置包 */ typedef struct _USB_SETUP_PACKET { REQUEST_TYPE bmRequestType; BYTE bRequest; WORD_BYTE wValue; WORD_BYTE wIndex; WORD wLength; } USB_SETUP_PACKET; 1.bmRequestType 是包含有下面

USB系列之二:读取USB设备的描述符

在前面的文章中,我们已经给出了USB协议的链接地址,从这篇文章起,我们会涉及到许多USB 1.1的内容,我们的指导思想是先从熟悉USB 1.1协议入手,先使用现成的HCD和USBD,直接面对客户端驱动编程,尽快看到成果,使读者对USB的开发充满信心,进而去研究USBD和HCD的编程方法.请读者自行阅读协议,文章中有关协议的详细情况,由于会涉及非常多的文字,恕不能过多解释.1.USB系统主机端的软件结构    一般来说,教科书或者协议上都会把USB主机端的软件说成有三层,第一层叫主机控制器驱动程序

USB设备描述符

/* USB Standard Device Descriptor */ const u8 Virtual_Com_Port_DeviceDescriptor[] = { 0x12, /* bLength */ //USB设备描述符的总长度固定为18个字节,因此为12H USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ //USB设备描述符的类型值,固定为01H 0x00, //USB遵循的规范版本号,USB2.0; 0xXXYZ,XX为主版本号

qq2440启动linux后插入u盘出现usb 1-1: device descriptor read/64, error -110,usb 1-1: device not accepting address 8, error -110

上位机:ubuntu14.04 64bit 下位机:qq2440 交叉编译器:arm-linux-gcc 3.4.1 下位机使用的linux内核版本:kernel2.6.13 1.插入u盘时错误信息如下: [[email protected] /home]# usb 1-1: new full speed USB device using s3c2410-ohci and address 6usb 1-1: device descriptor read/64, error -110usb 1-1

转 关于USB HID报告描述符

原文地址 USB HID报告及报告描述符简介 在USB中,USBHOST是通过各种描述符来识别设备的,有设备描述符,配置描述符,接口描述符,端点描述符,字符串描述符,报告描述符等等.USB报 告描述符(ReportDescriptor)是HID设备中的一个描述符,它是比较复杂的一个描述符.USBHID设备是通过报告来给传送数据的,报告 有输入报告和输出报告.输入报告是USB设备发送给主机的,例如USB鼠标将鼠标移动和鼠标点击等信息返回给电脑,键盘将按键数据数据返回给电脑等:输出 报告是主机发送在

OpenCV4Android 提取特征点描述符(Feature Descriptor)

OpenCV4Android 提取特征点描述符(Feature Descriptor) 在得到keypoints之后(参考前面),通过使用相应的FeatureDescriptor就可计算得到关键点处的描述子. Native Code: JNIEXPORT void JNICALL Java_com_example_test_NativeUtil_computeDescripors( JNIEnv *env, jclass thiz, jlong mGrayAddr, jlong mRgbaAdd

iphone手机连接USB时出现需要Mobile device setup disk上的usbaapl.sys文件

问题: iphone5 手机连接USB出现如下弹框 解决方法: 定位到C:\Program Files\Common Files\Apple\Mobile Device Support\Drivers\usbaapl.sys, 完后安装usbaapl.sys就可以解决问题了. iphone手机连接USB时出现需要Mobile device setup disk上的usbaapl.sys文件,布布扣,bubuko.com

Python描述符(descriptor)解密

Python中包含了许多内建的语言特性,它们使得代码简洁且易于理解.这些特性包括列表/集合/字典推导式,属性(property).以及装饰器(decorator).对于大部分特性来说,这些"中级"的语言特性有着完善的文档,并且易于学习. 但是这里有个例外,那就是描述符.至少对于我来说,描述符是Python语言核心中困扰我时间最长的一个特性.这里有几点原因如下: 有关描述符的官方文档相当难懂,而且没有包含优秀的示例告诉你为什么需要编写描述符(我得为Raymond Hettinger辩护一

java web实现img读取盘符下的图像

最近做了一个项目,用户上传图片后通过img控件显示出来.大家都知道img通过src属性就可以显示图片.如<img src="http://127.0.0.1/a/b/abc.jpg">.这样做没有任何问题,相信很多朋友也是这么做的. 但是这样做有个问题,图片必须是放在应用下面的.而且如果做了集群的话,那么图片就分散在富多个应用下面,很不好管理.这是我们自然会想到要是将图片放在一个地方就好了,最好是在应用外面,比如c盘的img目录下面.当然这样上传图片是很好做,但是要读取图片