linux HID

转载 2013年12月03日 23:44:37
//Linux设备驱动之HID驱动 源码分析
http://blog.chinaunix.net/uid-20543183-id-1930836.html

HID是Human Interface Devices的缩写.翻译成中文即为人机交互设备.这里的人机交互设备是一个宏观上面的概念,任何设备,只要符合HID spec,都可以称之为HID设备.常见的HID设备有鼠标键盘,游戏操纵杆等等.在接下来的代码分析中,可以参考HID的spec.这份spec可以在www.usb.org上找到.分析的代码主要集中在linux-2.6.25/drivers/hid目录下.

对此设备结点的处理有两种接口,一种是read(),另一种是ioctl();

  • read(): This is the event interface. When the HID device performs an interrupt transfer, indicating a change of state, data will be made available at the associated hiddev device with the content of a struct hiddev_event:struct hiddev_event { unsigned hid; signed int value; };containing the HID usage identifier for the status that changed, and the value that it was changed to.
  • ioctl(): This is the control interface. There are a number of controls:
    HIDIOCGVERSION int (read) Gets the version code out of the hiddev driver.
    HIDIOCAPPLICATION (none) This ioctl call returns the HID application usage associated with the hid device. The third argument to ioctl() specifies which application index to get. This is useful when the device has more than one application collection. If the index is invalid (greater or equal to the number of application collections this device has) the ioctl returns -1. You can find out beforehand how many application collections the device has from the num_applications field from the hiddev_devinfo structure.
    HIDIOCGDEVINFO struct hiddev_devinfo (read) Gets a hiddev_devinfo structure which describes the device.
    HIDIOCGSTRING struct struct hiddev_string_descriptor (read/write) Gets a string descriptor from the device. The caller must fill in the "index" field to indicate which descriptor should be returned.
    HIDIOCINITREPORT   Instructs the kernel to retrieve all input and feature report values from the device. At this point, all the usage structures will contain current values for the device, and will maintain it as the device changes.
    HIDIOCGNAME string (variable length) Gets the device name
    HIDIOCGREPORT struct hiddev_report_info (write) Instructs the kernel to get a feature or input report from the device, in order to selectively update the usage structures (in contrast to INITREPORT).
    HIDIOCSREPORT struct hiddev_report_info (write) Instructs the kernel to send a report to the device. This report can be filled in by the user throughHIDIOCSUSAGE calls (below) to fill in individual usage values in the report before sending the report in full to the device.
    HIDIOCGREPORTINFO struct hiddev_report_info (read/write) Fills in a hiddev_report_info structure for the user. The report is looked up by type (input, output or feature) and id, so these fields must be filled in by the user. The ID can be absolute -- the actual report id as reported by the device -- or relative -- HID_REPORT_ID_FIRST for the first report, and (HID_REPORT_ID_NEXT | report_id) for the next report after report_id. Without a-priori information about report ids, the right way to use this ioctl is to use the relative IDs above to enumerate the valid IDs. The ioctl returns non-zero when there is no more next ID. The real report ID is filled into the returned hiddev_report_info structure.
    HIDIOCGFIELDINFO struct hiddev_field_info (read/write) Returns the field information associated with a report in a hiddev_field_info structure. The user must fill in report_id and report_type in this structure, as above. The field_index should also be filled in, which should be a number from 0 and maxfield-1, as returned from a previous HIDIOCGREPORTINFO call.
    HIDIOCGUCODE struct hiddev_usage_ref (read/write) Returns the usage_code in a hiddev_usage_ref structure, given that given its report type, report id, field index, and index within the field have already been filled into the structure.
    HIDIOCGUSAGE struct hiddev_usage_ref (read/write) Returns the value of a usage in a hiddev_usage_ref structure. The usage to be retrieved can be specified as above, or the user can choose to fill in the report_type field and specify the report_id asHID_REPORT_ID_UNKNOWN. In this case, the hiddev_usage_ref will be filled in with the report and field infomation associated with this usage if it is found.
    HIDIOCSUSAGE struct hiddev_usage_ref (write) Sets the value of a usage in an output report.



http://blog.csdn.net/acf/article/details/5431488
在Linux 2.6环境下读写HID设备(USB Key)

      Linux 2.6内核中包含了HID驱动,能够自动把USB Key等HID外设识别成“/dev/hiddev0”之类的设备。但是该驱动没有实现write接口,因此无法象Windows平台那样使用 ReadFile和WriteFile来读写HID设备,而只能使用ioctl接口。
      网上有各种各样读写HID设备的源代码例子,有的是通过HIDIOCSUSAGE和HIDIOCGUSAGE来每次收发4个字节,适合鼠标、键盘之类数据传输量小的设备;有的是通过HIDIOCSUSAGES和HIDIOCGUSAGES来连续接收和发送多个字节,适合USB Key一类的设备。
      在上一篇日志(已删除)中,介绍了如何利用《USB and PIC: quick guide to an USB HID framework》一文提供的方法与USB Key进行通信(先发送HIDIOCSUSAGES和HIDIOCSREPORT进行写操作,再发送HIDIOCGREPORT和HIDIOCGUSAGES进行读操作,从而完成一次通信过程)。但是经过好友测试,发现该方法不论是在PC机上,还是在Cavium Octeon 52XX开发板上均存在问题,读出的数据始终是第一次通信的结果,除非在每次通信之前都发送HIDIOCINITREPORT控制码,但这又会造成相当长时间的阻塞。
      进一步的测试表明,如果按照HIDIOCGUCODE、HIDIOCSUSAGES、HIDIOCSREPORT、HIDIOCGUCODE、HIDIOCGUSAGES的顺序发送控制码,那么可以每次都读出正确数据。不过该方法虽然在PC机上只需400毫秒延时,但是在Octeon开发板上仍会长时间阻塞在usbhid_wait_io函数那里。
      无奈之下,我只好根据Cavium SDK自带的Linux内核源码中的usb_skeleton.c写了一个USB设备驱动程序,试图通过直接读写USB端点来完成通信过程。以下是在开发和调试过程中需要注意的几个问题:
      首先,必须卸载Linux内核自带的HID驱动,否则它会自动“接管”新插入的USB Key,导致我们自己编写的驱动程序找不到设备。对于开发板,可以在编译内核时去掉HID相关的选项;对于PC机上已经安装好的Linux,我也不知道该怎么卸载其中的HID驱动。
      其次,端点类型。在usb_skeleton.c中是通过bulk端点来访问USB设备的,而USB Key作为HID设备,一般只有0号控制端点和一个中断输入端点(例如3号)。对于中断端点,可以用usb_interrupt_msg(其实就是usb_bulk_msg)函数进行访问;对于控制端点,则稍微麻烦一些,因为除了数据,还需要构造一个8字节的setup包。有关setup包的详细结构,可以参考USB和HID规范。获取setup包具体数值最简单的方法,就是在Windows环境下用BusHound观察USB Key的通信过程。
      最后,关于Report ID。在Windows环境下通过ReadFile和WriteFile访问HID设备时,必须在数据开头附加1字节的Report ID(一般为0)。在Linux环境下,如果使用HID驱动的ioctl接口,那么需要在hiddev_usage_ref结构中指定Report ID;如果使用自己编写的USB驱动程序,则不需要考虑Report ID,直接发送数据就得了。
      经过测试,利用自己编写的驱动程序,可以在Octeon开发板上正确读写HID类型的USB Key,而且读写之间的时间间隔也可以缩短至50毫秒。

从内核2.6.34 的代码来看,/dev/hidraw0只能操作 endpoint 0,即通用的控制通道,强行向其写入数据会提示

  write: Broken pipe

在内核 2.6.35以后进行了修正, 参考如下:

https://patchwork.kernel.org/patch/99990/

点击(此处)折叠或打开

  1. diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
  2. index 56d06cd..6fd833d 100644
  3. --- a/drivers/hid/usbhid/hid-core.c
  4. +++ b/drivers/hid/usbhid/hid-core.c
  5. static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count,
  6. unsigned char report_type)
  7. {
  8. struct usbhid_device *usbhid = hid->driver_data;
  9. struct usb_device *dev = hid_to_usb_dev(hid);
  10. struct usb_interface *intf = usbhid->intf;
  11. struct usb_host_interface *interface = intf->cur_altsetting;
  12. int ret;
  13. - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
  14. - HID_REQ_SET_REPORT,
  15. - USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  16. - ((report_type + 1) << 8) | *buf,
  17. - interface->desc.bInterfaceNumber, buf + 1, count - 1,
  18. - USB_CTRL_SET_TIMEOUT);
  19. -
  20. - /* count also the report id */
  21. - if (ret > 0)
  22. - ret++;
  23. + if (usbhid->urbout) {
  24. + int actual_length;
  25. + int skipped_report_id = 0;
  26. + if (buf[0] == 0x0) {
  27. + /* Don't send the Report ID */
  28. + buf++;
  29. + count--;
  30. + skipped_report_id = 1;
  31. + }
  32. + ret = usb_interrupt_msg(dev, usbhid->urbout->pipe,
  33. + buf, count, &actual_length,
  34. + USB_CTRL_SET_TIMEOUT);
  35. + /* return the number of bytes transferred */
  36. + if (ret == 0) {
  37. + ret = actual_length;
  38. + /* count also the report id */
  39. + if (skipped_report_id)
  40. + ret++;
  41. + }
  42. + } else {
  43. + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
  44. + HID_REQ_SET_REPORT,
  45. + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  46. + ((report_type + 1) << 8) | *buf,
  47. + interface->desc.bInterfaceNumber, buf + 1, count - 1,
  48. + USB_CTRL_SET_TIMEOUT);
  49. + /* count also the report id */
  50. + if (ret > 0)
  51. + ret++;
  52. + }
  53. return ret;
  54. }


hid-example.c,来演示如何操作
  http://www.emdebian.org/~zumbi/kernel/linux-2.6-3.0.0~rc1/samples/hidraw/hid-example.c

点击(此处)折叠或打开

  1. /*
  2.  * Hidraw Userspace Example
  3.  *
  4.  * Copyright (c) 2010 Alan Ott <alan@signal11.us>
  5.  * Copyright (c) 2010 Signal 11 Software
  6.  *
  7.  * The code may be used by anyone for any purpose,
  8.  * and can serve as a starting point for developing
  9.  * applications using hidraw.
  10.  */

  11. /* Linux */
  12. #include <linux/types.h>
  13. #include <linux/input.h>
  14. #include <linux/hidraw.h>

  15. /*
  16.  * Ugly hack to work around failing compilation on systems that don't
  17.  * yet populate new version of hidraw.to userspace.
  18.  *
  19.  * If you need this, please have your distro update the kernel headers.
  20.  */
  21. #ifndef HIDIOCSFEATURE
  22. #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
  23. #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
  24. #endif

  25. /* Unix */
  26. #include <sys/ioctl.h>
  27. #include <sys/types.h>
  28. #include <sys/stat.h>
  29. #include <fcntl.h>
  30. #include <unistd.h>

  31. /* C */
  32. #include <stdio.h>
  33. #include <string.h>
  34. #include <stdlib.h>
  35. #include <errno.h>

  36. const char *bus_str(int bus);

  37. int main(int argc, char **argv)
  38. {
  39.     int fd;
  40.     int i, res, desc_size = 0;
  41.     char buf[256];
  42.     struct hidraw_report_descriptor rpt_desc;
  43.     struct hidraw_devinfo info;

  44.     /* Open the Device with non-blocking reads. In real life,
  45.      don't use a hard coded path; use libudev instead. */
  46.     fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK);

  47.     if (fd < 0) {
  48.         perror("Unable to open device");
  49.         return 1;
  50.     }

  51.     memset(&rpt_desc, 0x0, sizeof(rpt_desc));
  52.     memset(&info, 0x0, sizeof(info));
  53.     memset(buf, 0x0, sizeof(buf));

  54.     /* Get Report Descriptor Size */
  55.     res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size);
  56.     if (res < 0)
  57.         perror("HIDIOCGRDESCSIZE");
  58.     else
  59.         printf("Report Descriptor Size: %d\n", desc_size);

  60.     /* Get Report Descriptor */
  61.     rpt_desc.size = desc_size;
  62.     res = ioctl(fd, HIDIOCGRDESC, &rpt_desc);
  63.     if (res < 0) {
  64.         perror("HIDIOCGRDESC");
  65.     } else {
  66.         printf("Report Descriptor:\n");
  67.         for (= 0; i < rpt_desc.size; i++)
  68.             printf("%hhx ", rpt_desc.value[i]);
  69.         puts("\n");
  70.     }

  71.     /* Get Raw Name */
  72.     res = ioctl(fd, HIDIOCGRAWNAME(256), buf);
  73.     if (res < 0)
  74.         perror("HIDIOCGRAWNAME");
  75.     else
  76.         printf("Raw Name: %s\n", buf);

  77.     /* Get Physical Location */
  78.     res = ioctl(fd, HIDIOCGRAWPHYS(256), buf);
  79.     if (res < 0)
  80.         perror("HIDIOCGRAWPHYS");
  81.     else
  82.         printf("Raw Phys: %s\n", buf);

  83.     /* Get Raw Info */
  84.     res = ioctl(fd, HIDIOCGRAWINFO, &info);
  85.     if (res < 0) {
  86.         perror("HIDIOCGRAWINFO");
  87.     } else {
  88.         printf("Raw Info:\n");
  89.         printf("\tbustype: %d (%s)\n",
  90.             info.bustype, bus_str(info.bustype));
  91.         printf("\tvendor: 0x%04hx\n", info.vendor);
  92.         printf("\tproduct: 0x%04hx\n", info.product);
  93.     }

  94.     /* Set Feature */
  95.     buf[0] = 0x9; /* Report Number */
  96.     buf[1] = 0xff;
  97.     buf[2] = 0xff;
  98.     buf[3] = 0xff;
  99.     res = ioctl(fd, HIDIOCSFEATURE(4), buf);
  100.     if (res < 0)
  101.         perror("HIDIOCSFEATURE");
  102.     else
  103.         printf("ioctl HIDIOCGFEATURE returned: %d\n", res);

  104.     /* Get Feature */
  105.     buf[0] = 0x9; /* Report Number */
  106.     res = ioctl(fd, HIDIOCGFEATURE(256), buf);
  107.     if (res < 0) {
  108.         perror("HIDIOCGFEATURE");
  109.     } else {
  110.         printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
  111.         printf("Report data (not containing the report number):\n\t");
  112.         for (= 0; i < res; i++)
  113.             printf("%hhx ", buf[i]);
  114.         puts("\n");
  115.     }

  116.     /* Send a Report to the Device */
  117.     buf[0] = 0x1; /* Report Number */
  118.     buf[1] = 0x77;
  119.     res = write(fd, buf, 2);
  120.     if (res < 0) {
  121.         printf("Error: %d\n", errno);
  122.         perror("write");
  123.     } else {
  124.         printf("write() wrote %d bytes\n", res);
  125.     }

  126.     /* Get a report from the device */
  127.     res = read(fd, buf, 16);
  128.     if (res < 0) {
  129.         perror("read");
  130.     } else {
  131.         printf("read() read %d bytes:\n\t", res);
  132.         for (= 0; i < res; i++)
  133.             printf("%hhx ", buf[i]);
  134.         puts("\n");
  135.     }
  136.     close(fd);
  137.     return 0;
  138. }

  139. const char *
  140. bus_str(int bus)
  141. {
  142.     switch (bus) {
  143.     case BUS_USB:
  144.         return "USB";
  145.         break;
  146.     case BUS_HIL:
  147.         return "HIL";
  148.         break;
  149.     case BUS_BLUETOOTH:
  150.         return "Bluetooth";
  151.         break;
  152.     case BUS_VIRTUAL:
  153.         return "Virtual";
  154.         break;
  155.     default:
  156.         return "Other";
  157.         break;
  158.     }
  159. }



//----- openwrt 下安装和调试

root@OpenWrt:~# opkg install kmod-usb-hid --force-depends
Installing kmod-usb-hid (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-hid_3.3.8-1_ar71xx.ipk.
Installing kmod-hid (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-hid_3.3.8-1_ar71xx.ipk.
Installing kmod-input-evdev (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-input-evdev_3.3.8-1_ar71xx.ipk.
Configuring kmod-input-evdev.
Configuring kmod-hid.
Configuring kmod-usb-hid.
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-usb-hid:
 *      kernel (= 3.3.8-1-231112e548aba152810eababd16134bc) *   kernel (= 3.3.8-1-231112e548aba152810eababd16134bc) *   kernel (= 3.3.8-1-231112e548aba152810eababd16134bc) * 
 
root@OpenWrt:~# lsmod | grep hid
usbhid                 20688  0 [permanent]
hid                    64032  1 usbhid,[permanent]
usbcore                99168 19 usbhid,uvcvideo,gspca_zc3xx,gspca_main,ums_usbat,ums_sddr55,ums_sddr09,ums_karma,ums_jumpshot,ums_isd200,ums_freecom,ums_datafab,ums_cypress,ums_alauda,usb_storage,uhci_hcd,ohci_hcd,ehci_hcd
input_core             20016  7 usbhid,hid,evdev,uvcvideo,gspca_zc3xx,gspca_main

# 插上usb hub, 无法发现hid设备(原因: hub的红线为电源线, 白线为数据线)
root@OpenWrt:~# dmesg | grep hid
[   12.000000] usbcore: registered new interface driver usbhid
[   12.010000] usbhid: USB HID core driver
 
# 无hub, 直接接上hid设备, 可以找到设备
root@OpenWrt:~# dmesg | grep hid
[   12.000000] usbcore: registered new interface driver usbhid
[   12.010000] usbhid: USB HID core driver
[  185.290000] generic-usb 0003:0483:D0D0.0001: hiddev0: USB HID v1.10 Device [STMicroelectronics CR95HF] on usb-ehci-platform-1/input1

# hid设备标识符, 不是 标准的 /dev/hiddev0
root@OpenWrt:~# ls /dev/hid*
ls: /dev/hid*: No such file or directory

root@OpenWrt:~# ls -al /dev/usb/hid*
crw-r--r--    1 root     root      180,  96 Jan  1 00:03 /dev/usb/hiddev0

# 去除设备, 无标识符. 
root@OpenWrt:~# ls -al /dev/usb/hid*
ls: /dev/usb/hid*: No such file or directory

# 插拔3次, 
root@OpenWrt:~# dmesg | grep hid
[   12.000000] usbcore: registered new interface driver usbhid
[   12.010000] usbhid: USB HID core driver
[  185.290000] generic-usb 0003:0483:D0D0.0001: hiddev0: USB HID v1.10 Device [STMicroelectronics CR95HF] on usb-ehci-platform-1/input1
[ 1034.170000] generic-usb 0003:0483:D0D0.0002: hiddev0: USB HID v1.10 Device [STMicroelectronics CR95HF] on usb-ehci-platform-1/input1
[ 1085.970000] generic-usb 0003:0483:D0D0.0003: hiddev0: USB HID v1.10 Device [STMicroelectronics CR95HF] on usb-ehci-platform-1/input1


root@OpenWrt:~# find / -name hid*
/dev/usb/hiddev0
/lib/modules/3.3.8/hid.ko
/overlay/lib/modules/3.3.8/hid.ko
/sys/devices/platform/ehci-platform/usb1/1-1/1-1:1.1/usb/hiddev0
/sys/bus/hid
/sys/class/usb/hiddev0
/sys/kernel/debug/hid
/sys/module/input_core/holders/hid
/sys/module/hid
/sys/module/usbhid/drivers/hid:generic-usb

-----------------------------------------------------------------
root@OpenWrt:/xutest# opkg install hid_xu1_ar71xx.ipk
Installing hid (xu1) to root...
Configuring hid.
root@OpenWrt:/xutest# hidtest
/dev/hiddev0 information: 
HIDIOCGVERSION: 1.4
HIDIOCGDEVINFO: bustype=3 busnum=1 devnum=4 ifnum=1
        vendor=0x0483 product=0xd0d0 version=0x0200
        num_applications=1
HIDIOCGNAME: STMicroelectronics CR95HF
Reports of type Input (1):
Report id: 7 (1 fields)
 Field: 0: app: 8c0001 phys 0000 flags 2 (63 usages) unit 0 exp 0
Reports of type Output (2):
Report id: 1 (1 fields)
 Field: 0: app: 8c0001 phys 0000 flags 2 (63 usages) unit 0 exp 0
Report id: 2 (1 fields)
 Field: 0: app: 8c0001 phys 0000 flags 2 (63 usages) unit 0 exp 0
Reports of type Feature (3):
Waiting for events ... (interrupt to exit)
^C
root@OpenWrt:/xutest# 



下位机修改如下:

点击(此处)折叠或打开

  1. #if 1
  2. ucNeedSend = 1;

  3. Pos = HID_OFFSET_LENGTH + 1;
  4. #if 0
  5. ucSendData = 64;
  6. for (i=0; i<ucSendData-2; i++)
  7. SendBuffer[i+Pos] = 0x70 + i;

  8. #else
  9. ucSendData = RcvBuffer[HID_OFFSET_LENGTH];
  10. for (i=0; i<ucSendData-2; i++)
  11. SendBuffer[i+Pos] = RcvBuffer[i+Pos];
  12. #endif

  13.     if (ucNeedSend) {
  14.         /* SendBuffer format
  15.             1st byte     : ID_SEND_HID_RESPONSE
  16.             2nd byte     : repply or error code flag
  17.             3rd byte     : nb byte
  18.             others bytes: data

  19.             #define HID_SEND_HID_RESPONSE                0x07
  20.             #define HID_OFFSET                            0x00
  21.             #define HID_OFFSET_CMDCODE            HID_OFFSET + 1
  22.             #define HID_OFFSET_LENGTH                HID_OFFSET + 2
  23.         */
  24.         SendBuffer[HID_OFFSET] = HID_SEND_HID_RESPONSE;
  25.         //SendBuffer[HID_OFFSET_LENGTH] = MIN(HID_MAX_BUFFER_SIZE, SendBuffer[HID_OFFSET_LENGTH]);
  26.         SendBuffer[HID_OFFSET_LENGTH] = ucSendData;

  27.         /* Allows the transmission */
  28.         SetEPTxStatus(ENDP3, EP_TX_VALID);
  29.         USB_SIL_Write(EP3_IN, SendBuffer, HID_MAX_BUFFER_SIZE);
  30.     }

路由器上调试如下:
root@OpenWrt:/xutest# hidtest /dev/hiddev0
/dev/hiddev0 information: 
HIDIOCGDEVINFO: bustype=3 busnum=1 devnum=11 ifnum=1
        vendor=0x0483 product=0xd0d0 version=0x0200
        num_applications=1
VID = 0x483, PID = 0xffffd0d0
--find device
HIDIOCGNAME: STMicroelectronics CR95HF

Reports of type Input (1):
Report id: 0x07 (1 fields)

Reports of type Output (2):
Report id: 0x01 (1 fields)
Report id: 0x02 (1 fields)

Reports of type Feature (3):
5A 08 01 02 03 04 05 06 
00 08 01 02 03 04 05 06 

5A 0A 10 11 12 13 14 15 16 17 
00 0A 10 11 12 13 14 15 16 17 

5A 0B 70 71 72 73 74 75 76 77 78 
00 0B 70 71 72 73 74 75 76 77 78 

5A 0C 10 11 12 13 14 15 16 17 18 19 
00 0C 10 11 12 13 14 15 16 17 18 19 

5A 0D 70 71 72 73 74 75 76 77 78 79 7A 
00 0D 70 71 72 73 74 75 76 77 78 79 7A 

5A 0E 10 11 12 13 14 15 16 17 18 19 1A 1B 
00 0E 10 11 12 13 14 15 16 17 18 19 1A 1B 

5A 0F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 
00 0F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 

5A 10 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 
00 10 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 

5A 11 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 
00 11 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 

5A 12 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
00 12 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 

5A 13 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 
00 13 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 


1. 利用libusb 实现的hid 读写
写入用usb_interrupt_write
读取用usb_interrupt_read

Linux 下的 hid dev 设备编程处理

Linux下HID 设备,如果非标准的输入设备(Keypad/MOUSE/JoyStick/input event device). 将会把信息转入hid device的设备结点。 这一点...

如何在Linux下利用Libusb与HID USB设备通信!

由于公司的产品,导致我在Linux下写usb通信的代码出现了许多的问题,最后发现这些设备只能通过控制传输来操作设备,所以后面的问题就迎刃而解了。现在贴上当时在QT下写的代码,以防日后再碰到此类问题的时...

LINUX下USB1.1设备学习小记(6)_hid与input子系统(3)

LINUX下USB1.1设备学习小记(6)_hid与input子系统(3)   http://cupidove.blog.163.com/blog/static/100566220119206136...

Linux下 hid quirks的研究

者:Sam (甄峰) sam_code@hotmail.com   Sam在读USB HIDdriver时,看到quirks这部分内容。因为之前在看USB部分代码时,常看到类似的内容,但对它的语义...

Linux Gadget的一点研究之HID设备

接上文,配置编译gadget HID模块 make modules后在driver/usb/gadget目录下生成g_hid.ko 执行加载命令: root@rfODNCC:/mnt# insm...

linux 自定义hid速度优化

参考文章: http://blog.chinaunix.net/uid-25445243-id-4040449.html http://www.cnblogs.com/xidongs/archive...
  • hclydao
  • hclydao
  • 2016年01月14日 14:00
  • 2831

Bluez HID分析--Linux kernel部分

本文介绍蓝牙协议栈Bluez在linux中实现HID功能的kernel部分。 在linux kernel中,Bluez对HID的实现代码在/net/bluetooth/hidp文件夹中,主要包括so...

linux HID驱动分析

最近研究蓝牙的键盘鼠标,所以粗略看了一下Linux的HID框架。 HID 总线 HID的总线在hid-core.c的hid-init中初始化: bus_register(&hid_bus_typ...

Windows,Linux,Mac系统中,USB HID枚举过程的异同

http://www.crifan.com/order_windows_linux_mac_systems_usb_hid_similarities_and_differences_between_t...

linux HID驱动分析 .

最近研究蓝牙的键盘鼠标,所以粗略看了一下Linux的HID框架。 HID 总线 HID的总线在hid-core.c的hid-init中初始化: bus_register(&hid_bus_typ...
  • bjash
  • bjash
  • 2013年01月23日 23:37
  • 1016
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:linux HID
举报原因:
原因补充:

(最多只允许输入30个字)