传输时libusb LIBUSB_ERROR_IO

时间:2016-05-21 22:11:28

标签: c libusb

我正在运行下面的程序,它在尝试传输数据时返回错误代码(-1,LIBUSB_ERROR_IO,字节发送:0)。我使用的是libusb-1.0 dll。

#include <stdio.h>
#include "inc/libusb.h"

int main(void) {
    libusb_device_handle *dev_handle;

    unsigned char buf[5] = {0x04, 0x00, 0x06, 0x06, 0x00};

    int r, bytes_sent = 0;

    if(libusb_init(NULL)) return 1;
    dev_handle = libusb_open_device_with_vid_pid(NULL, 0x1b1c, 0x0c04);
    libusb_claim_interface(dev_handle, 0);

    r = libusb_interrupt_transfer(dev_handle, 0x81, buf, 5, &bytes_sent, 0);

    printf("Return code: %d\nBytes sent: %d\n", r, bytes_sent);

    libusb_release_interface(dev_handle, 0);
    libusb_close(dev_handle);
    libusb_exit(NULL);

    return 0;
}

另外,我不确定我使用的是正确的端点地址。这些是来自usbview的一些图片:http://i.imgur.com/4FFaOkq.pnghttp://i.imgur.com/B9cEoV6.png。第一个显示我正在尝试与之通信的设备。由于在第一图像中从设备提供的信息不多,因此我使用来自第二图像的信息。我是正确的假设我需要使用与此设备的中断通信,从端点描述符下的传输类型判断?

最后,libusb可能不适合与特定设备通信,我需要使用另一个库吗?(例如,hidapi)

0 个答案:

没有答案