首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >国产USB笔设备只在Windows 7/ Linux上工作

国产USB笔设备只在Windows 7/ Linux上工作
EN

Stack Overflow用户
提问于 2014-11-27 09:19:44
回答 2查看 1.6K关注 0票数 1

我(用STM32F4微控制器)制作了一个USB设备。我的设备在Windows 7或Debian 7 (Linux)上工作得很好。

问题是=>不适用于Windows 8、8.1、10 .

我的设备被识别为"HID Stylus",usb视图给我没有错误,管道是打开的,但我的光标不会移动。更糟糕的是,我没有看到任何数据包进出UsbLyzer!

编辑:

代码语言:javascript
复制
 On windows 7 = PowerDevice = stay @ D0
 On windows 8 = PowerDevice = D0 1s an then = D3

以下是计算机如何看待我的设备(usbview):

代码语言:javascript
复制
    Device Descriptor:
    bcdUSB:             0x0200
    bDeviceClass:         0x00
    bDeviceSubClass:      0x00
    bDeviceProtocol:      0x00
    bMaxPacketSize0:      0x40 (64)
    idVendor:           0xFFFF
    idProduct:          0x0001
    bcdDevice:          0x0200
    iManufacturer:        0x01
    0x0409: "homemade"
    iProduct:             0x02
    0x0409: "Homemade usb pen device"
    iSerialNumber:        0x03
    0x0409: "00000000050C"
    bNumConfigurations:   0x01

    ConnectionStatus: DeviceConnected
    Current Config Value: 0x01
    Device Bus Speed:     Full
    Device Address:       0x0D
    Open Pipes:              1

    Endpoint Descriptor:
    bEndpointAddress:     0x81  IN
    Transfer Type:   Interrupt
    wMaxPacketSize:     0x000B (11)
    bInterval:            0x0A

    Configuration Descriptor:
    wTotalLength:       0x0022
    bNumInterfaces:       0x01
    bConfigurationValue:  0x01
    iConfiguration:       0x00
    bmAttributes:         0x80 (Bus Powered )
    MaxPower:             0xFA (500 Ma)

    Interface Descriptor:
    bInterfaceNumber:     0x00
    bAlternateSetting:    0x00
    bNumEndpoints:        0x01
    bInterfaceClass:      0x03 (HID)
    bInterfaceSubClass:   0x01
    bInterfaceProtocol:   0x02
    iInterface:           0x00

    HID Descriptor:
    bcdHID:             0x0111
    bCountryCode:         0x00
    bNumDescriptors:      0x01
    bDescriptorType:      0x22
    wDescriptorLength:  0x0092

    Endpoint Descriptor:
    bEndpointAddress:     0x81  IN
    Transfer Type:   Interrupt
    wMaxPacketSize:     0x000B (11)
    bInterval:            0x0A

这是我的设备HID描述符:

代码语言:javascript
复制
0x05, 0x0d,                         // USAGE_PAGE (Digitizers)
0x09, 0x02,                         // USAGE (Pen)

0xa1, 0x01,                         // COLLECTION (Application)
0x09, 0x02,                         //   USAGE (pen)

0xa1, 0x00,                         //   COLLECTION (Physical)

0x09, 0x42,                         //     USAGE (Tip Switch)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x25, 0x01,                         //     LOGICAL_MAXIMUM (1)
0x75, 0x01,                         //     REPORT_SIZE (1)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x95, 0x03,                         //     REPORT_COUNT (3)
0x81, 0x03,                         //     INPUT (Cnst,Ary,Abs)

0x09, 0x32,                         //     USAGE (In Range)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x95, 0x03,                         //     REPORT_COUNT (3)
0x81, 0x03,                         //     INPUT (Cnst,Ary,Abs)

0x09, 0x56,                         //     USAGE (Scan time)
0x16, 0x00, 0x00,                   //     LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00,                   //     LOGICAL_MAXIMUM (255)
0x75, 0x08,                         //     REPORT_SIZE (8)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Ary,Abs)

// X TILT
0x09, 0x3d,                         //     USAGE (X tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

// Y TILT
0x09, 0x3e,                         //     USAGE (Y tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x05, 0x01,                         //     USAGE_PAGE (Generic Desktop)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0x08, 0x52,                   //     LOGICAL_MAXIMUM (21000) /// 0x08, 0x52, = 21000
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x30,                         //     USAGE (X)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0x08, 0x52,                   //     PHYSICAL_MAXIMUM (21000) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0xd0, 0x39,                   //     LOGICAL_MAXIMUM (14800) /// 0xd0, 0x39, = 14800
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x31,                         //     USAGE (Y)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0xd0, 0x39,                   //     PHYSICAL_MAXIMUM (14800) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs) 

0xc0,                               //   END_COLLECTION
0xc0,                               // END_COLLECTION
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-11-05 11:23:44

我改变了很多事情:

  • 改变我做填充的方式
  • 我不再发送扫描时间了
  • ……也许其他的很多事情不会改变很多

我终于做了一个能工作的设备!

这是我的带有IAD的usb配置描述符(HID Pen device + CDC)

/**********************配置描述符*

代码语言:javascript
复制
0x09,                                 /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType: Configuration */
USB_CONFIG_DESC_SIZE,                 /* wTotalLength: Bytes returned */
0x00,
0x03,                                 /*bNumInterfaces: 3 interface*/
0x01,                                 /*bConfigurationValue: Configuration value*/
0x01,                                 /*iConfiguration: Index of string descriptor describing the configuration*/
0x80,                                 /*bmAttributes: self powered  */
0xFA,                                 /*MaxPower 500 mA: this current is used for detecting Vbus*/
/* Total 09 */

/********************** HID数码化接口*

代码语言:javascript
复制
0x09,                             /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,    /*bDescriptorType: Interface descriptor type*/
0x00,                             /*bInterfaceNumber: Number of Interface*/
0x00,                             /*bAlternateSetting: Alternate setting*/
0x01,                             /*bNumEndpoints*/
0x03,                             /*bInterfaceClass: HID*/
0x00,                             /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00,                             /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0x00,                             /*iInterface: Index of string descriptor*/
/* Total 18 */
/******************** Descriptor of Digitizer HID ********************/
0x09,                             /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE,              /*bDescriptorType: HID*/
0x11,                             /*bcdHID: HID Class Spec release number*/
0x01,
0x00,                             /*bCountryCode: Hardware target country*/
0x01,                             /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22,                             /*bDescriptorType*/
HID_DIGITIZER_REPORT_DESC_SIZE,   /*wItemLength: Total length of Report descriptor*/
0x00,
/* Total 27 */
/******************** Descriptor of Digitizer endpoint ********************/
0x07,                             /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE,     /*bDescriptorType:*/
HID_IN_EP,                        /*bEndpointAddress: Endpoint Address (IN)*/
0x03,                             /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET_DIG,                /*wMaxPacketSize: 4 Byte max */
0x00,
0x03,                             /*bInterval: Polling Interval (3 ms)*/
/* Total 34 */  

/*****************接口关联描述符*

代码语言:javascript
复制
0x08,                               // Size of this descriptor in bytes
0x0B,                               // Interface association descriptor type
0x01,                               // First associated interface
0x02,                               // Number of contiguous associated interfaces
COMM_INTF,                          // bInterfaceClass of the first interface
ABSTRACT_CONTROL_MODEL,             // bInterfaceSubClass of the first interface
V25TER,                             // bInterfaceProtocol of the first interface
0x00,                               // Interface string index
/* Total 42 */

疾病控制中心的/*****************描述符*

代码语言:javascript
复制
// Interface Descriptor
0x09,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
CDC_COMM_INTF_ID,                   // Interface number
0x00,                               // Alternate setting number
0x01,                               // Number of endpoints in this interface
COMM_INTF,                          // Class code
ABSTRACT_CONTROL_MODEL,             // Subclass code
V25TER,                             // Protocol code
0x00,                               // Interface string index
/* Total 51 */

// CDC Class Specific
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_HEADER,                      // bDescriptorSubtype
0x20, 0x01,                         // bcdCDC
/* Total 56 */

// Abstract Control Management Functional Descriptor
0x04,                               // Size of this descriptor in bytes (4)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_ACM,                         // bDescriptorSubtype
USB_CDC_ACM_FN_DSC_VAL,             // bmCapabilities: (see PSTN120.pdf Table 4)
/* Total 60 */

// Union Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_UNION,                       // bDescriptorSubtype
0x01,                               // bControlInterface
0x02,                               // bSubordinateInterface0
/* Total 65 */

// Call Management Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_CALL_MGT,                    // bDescriptorSubtype
0x00,                               // bmCapabilities
0x02,                               // bDataInterface
/* Total 70 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes (7)
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_CMD_EP,                           // Endpoint address
_INTERRUPT,                         // Attributes
CDC_COMM_IN_EP_SIZE, 0x00,          // Size
0x02,                               // Interval
/* Total 77 */

// CDC Data Interface
0x09,                               // Size of this descriptor in bytes (9)
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
0x02,                               // Interface number
0x00,                               // Alternate setting number
0x02,                               // Number of endpoints in this interface
DATA_INTF,                          // Class code
0x00,                               // Subclass code
NO_PROTOCOL,                        // Protocol code
0x00,                               // Interface string index
/* Total 86 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_OUT_EP,                          // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00,                               // Interval
/* Total 93 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_IN_EP,                           // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00
/* Total 100 */

最后,我使用的HID描述符:

代码语言:javascript
复制
0x05, 0x0d,                         // USAGE_PAGE (Digitizers)
0x09, 0x01,                         // USAGE (Digitizers)
// +4
0xa1, 0x01,                         // COLLECTION (Application)
0x09, 0x02,                         //   USAGE (pen)
// +4
0xa1, 0x00,                         //   COLLECTION (Physical)
// +2
0x09, 0x42,                         //     USAGE (Tip Switch)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x25, 0x01,                         //     LOGICAL_MAXIMUM (1)
0x75, 0x01,                         //     REPORT_SIZE (1)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +12
0x09, 0x00,                         //     USAGE (Undefined / Padding)
0x75, 0x03,                         //     REPORT_SIZE (3)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x03,                         //     INPUT (Cnst,Var,Abs)
// +8
0x09, 0x32,                         //     USAGE (In Range)
0x75, 0x01,                         //     REPORT_SIZE (1)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +8
0x09, 0x00,                         //     USAGE (Undefined / Padding)
0x75, 0x03,                         //     REPORT_SIZE (3)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x03,                         //     INPUT (Cnst,Var,Abs)
// +8
// X TILT
0x09, 0x3d,                         //     USAGE (X tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +24
// Y TILT
0x09, 0x3e,                         //     USAGE (Y tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +24
0x05, 0x01,                         //     USAGE_PAGE (Generic Desktop)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0x08, 0x52,                   //     LOGICAL_MAXIMUM (21000) /// 0x08, 0x52, = 21000
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x30,                         //     USAGE (X)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0x08, 0x52,                   //     PHYSICAL_MAXIMUM (21000) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +24
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0xd0, 0x39,                   //     LOGICAL_MAXIMUM (14800) /// 0xd0, 0x39, = 14800
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x31,                         //     USAGE (Y)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0xd0, 0x39,                   //     PHYSICAL_MAXIMUM (14800) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs) 
// +22
0xc0,                               //   END_COLLECTION
0xc0,                               // END_COLLECTION
// +2
// TOTAL = 142
票数 0
EN

Stack Overflow用户

发布于 2019-05-31 12:08:11

您有在您的stm32f4板上运行linux时所遵循的步骤吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27166960

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档