libusb的中断传输 [英] libusb interrupt transfer

查看:4925
本文介绍了libusb的中断传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要逆向工程的驱动程序定制HID USB设备(一个控制面板上的一些按钮和指示灯)。该驱动程序仅在Windows上使用,我们需要一个* nix的实现。

I need to reverse engineer a driver for custom made HID USB device (some buttons and leds on an control panel). The driver is only available on Windows and we need a *nix implementation.

该设备显然是HID设备虽然不是一个特定的类。它提供了每两个接口与单个中断端点。

The device apparently is a HID device although not of a particular class. It provides two interfaces each with a single interrupt endpoint.

我的设置目前涉及到Ubuntu的主机上运行Windows的VirtualBox的通过Wireshark的捕获USB流量。该协议是相当简单,我已经获得了相当不错的理解。

My setup currently involves a VirtualBox running Windows on a Ubuntu host to capture the USB traffic via Wireshark. The protocol is rather simple and I already gained a rather good understanding.

我在原型设计简单的C ++控制台程序使用的libusb-1.0。我已经设法通过发行在转让通过中断接收按钮presses一个SET_REPORT控制转移,但斗争切换LED。

I am using libusb-1.0 in a simple C++ console program for prototyping. I already managed to toggle LEDs by issuing a SET_REPORT control transfer but struggle in receiving button presses via interrupt in transfers.

其实下面的调用块永远:

In fact the following call blocks forever:

unsigned char bytes[8] = { 0 };
int len = 0;
int ret = libusb_interrupt_transfer(handle, 0x81, bytes, 8, &len, 0); 

当检查结果URB在Wireshark的它看起来就像在Windows会话中捕获的等价物。不过我从来没有从设备的答复。

When inspecting the resulting URB in Wireshark it looks exactly like the equivalent captured at the Windows session. Still I never get a reply from the device.

我爱上我缺少一些设置。请注意,设备是否正常打开,由该设备提供的接口都已经成功地声称。通过控制传输的方式输入报告来了低谷,甚至在我的Linux应用程序。

I fell I am missing some setting. Note that the device is properly opened and both interfaces provided by the device have been sucessfully claimed. Input reports by means of control transfers are coming trough, even in my linux application.

感谢您的任何指针!
阿恩

Thanks for any pointer! Arne

附录I:
我想知道我怎么可以指定我想用的时候接受该报告ID libusb_interrupt_transfer()

附录二:
当比较由Windows驱动程序通过上述code Wireshark中我没有看到任何差别(在URB相同的值)生成一个提出的要求。但尽管如此,只有当Windows驱动程序的中断传输回报签发。

Addendum II: When comparing the requests made by the windows driver to the one generated by the above code in Wireshark I don't see any difference (same values in URB). But still, only when issued by the Windows driver the interrupt transfer returns.

在检查中Wireshark的Windows驱动程序通信我没有看到比其他各种的任何控制转移 GET_DESCRIPTOR(...)。最重要的是:没有 SET_INTERFACE SET_CONFIGURATION 因此,我怀疑问题是关系到图书馆或如何使用它,是的的相关设备。

When inspecting the Windows driver communication in Wireshark I dont see any control transfers other than various GET_DESCRIPTOR(...). Most important: no SET_INTERFACE or SET_CONFIGURATION Thus I suspect the problem is related to the library or how I use it and is not related to the device.

推荐答案

有与$ C $问题c您发布。语法你写定义字节不会导致8字节数组,但您请求的libusb到该地址写8个字节,所以你可能会得到一个错误或内存损坏。试试这个:

There is a problem with the code you posted. The syntax you wrote for defining bytes will not result in an 8-byte array, but you are requesting that libusb write 8 bytes in to that address so you might get an error or memory corruption. Try this instead:

unsigned char buffer[8];
int len = 0;
int ret = libusb_interrupt_transfer(handle, 0x81, buffer, sizeof(buffer), &len, 0);

每个HID报告都有自己的端点,让你指定报告要通过​​指定正确的端点接收。您指定端点1 IN(0×81)。你确定端点在设备的描述符中定义?也许你应该得到的描述符(带有 -v的lsusb 在Ubuntu中),并张贴在这里,所以我们可以检查它们。

Each HID report has its own endpoint, so you specify which report you want to receive by specifying the correct endpoint. You specified Endpoint 1 IN (0x81). Are you sure that endpoint is defined in the device's descriptors? Maybe you should get the descriptors (with lsusb -v in Ubuntu) and post them here so we can check them.

这篇关于libusb的中断传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆