LibUSB驱动程序问题:超时 [英] LibUSB driver issues: timeout

查看:995
本文介绍了LibUSB驱动程序问题:超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为打印机编写Linux驱动程序.我已经在Windows XP上运行USBSnoop并获得了日志.在此日志中,它将wMaxPacketSize设置为1026.设置接口后,我得到75字节的响应.如果我将其设置为64(在lsusb输出中),我显然只能得到64个字节.

I am attempting to write a linux driver for a printer. I have run USBSnoop on windows XP and obtained the log. In this log it sets wMaxPacketSize to 1026. After i set the interface i get the response of 75 bytes. If i set it to 64 (in the lsusb output) i obviously only get 64 bytes back.

我的问题是在我超时的设备之间进行批量传输.我认为我和这里有同样的问题:

My issue is on a bulk transfer to/from the device i get timeouts. I think i have the same problem as here: http://libusb.6.n5.nabble.com/libusb-bulk-transfer-return-timeout-error-and-transferred-set-to-0-td5712761.html

我执行了libusb_clear_halt(),并且得到的结果与上面的链接类似.它的底部说手动将缓冲区拆分为64个字节"以解决该问题.我的问题是如何拆分数据包?这是我第一次使用LibUSB.

I performed the libusb_clear_halt() and i get a similar result to the linked post above. Down the bottom of it says "split buffer into 64 bytes manually" to solve it. My question is how to split the packets? This is my first time using LibUSB.

这是lsusb -v的输出

Here is the output of lsusb -v

Bus 002 Device 009: ID 07ce:c000  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            7 Printer
  bDeviceSubClass         1 Printer
  bDeviceProtocol         2 Bidirectional
  bMaxPacketSize0        64
  idVendor           0x07ce 
  idProduct          0xc000 
  bcdDevice            1.00
  iManufacturer           1 COPAL
  iProduct                2 COPAL USB Printer
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              200mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         7 Printer
      bInterfaceSubClass      1 Printer
      bInterfaceProtocol      2 Bidirectional
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               0.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         0
  bNumConfigurations      0
Device Status:     0x0001
  Self Powered

这是在dmesg中

usb 2-1.1: new high-speed USB device number 9 using ehci_hcd
usb 2-1.1: config 1 interface 0 altsetting 0 bulk endpoint 0x1 has invalid maxpacket 64
usb 2-1.1: config 1 interface 0 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 64

我认为可能是linux正在妨碍您.在wireshark上,我可以看到数据包正确返回,但没有调用我的回调函数.我已经删除了usblp驱动程序.有任何想法吗?

I think it may be that linux is getting in the way. On wireshark and i can see the packets come back correctly but not calling my callback function. I already removed the usblp driver. Any ideas?

推荐答案

遇到了类似的问题.还没有弄清楚为什么我会收到超时错误.尽管对于较大的包装来说,它们似乎更经常出现.如果要拆分程序包,只需编写一个函数即可将大的buffer[1024]拆分为64字节的程序包,然后执行一个循环,该循环始终从缓冲区中提取下一个64字节,并将其放入small_buffer[64]并发送他们通过USB.

Got a similar problem. Haven't figured out why I get the timeout errors, yet. Though it seems like they occur much more often for larger package sizes. If you want to split your package, just write yourself a function that splits your large buffer[1024] into packages of 64 bytes, then do a loop that always takes the next 64 bytes from the buffer, puts it in a small_buffer[64] and sends them via usb.

这篇关于LibUSB驱动程序问题:超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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