LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1521|回复: 1

关于libusb

[复制链接]
发表于 2010-7-7 20:40:22 | 显示全部楼层 |阅读模式
请教一个关于libusb问题,
libusb_claim_interface(libusb_device_handle *dev,int interface_number).
总是出错,下面是log
libusb:debug [libusb_init]
libusb:debug [find_usbfs_path] found usbfs at /dev/bus/usb
libusb:debug [op_init] found usb devices in sysfs
libusb:debug [usbi_add_pollfd] add fd 3 events 1
libusb:debug [usbi_io_init] using timerfd for timeouts
libusb:debug [usbi_add_pollfd] add fd 5 events 1
libusb:debug [libusb_init] created default context
libusb:debug [libusb_get_device_list]
libusb:debug [sysfs_scan_device] scan usb1
libusb:debug [sysfs_scan_device] sysfs descriptors available
libusb:debug [sysfs_scan_device] bus=1 dev=1
libusb:debug [enumerate_device] busnum 1 devaddr 1 session_id 257
libusb:debug [enumerate_device] allocating new device for 1/1 (session 257)
libusb:debug [sysfs_scan_device] scan usb2
libusb:debug [sysfs_scan_device] bus=2 dev=1
libusb:debug [enumerate_device] busnum 2 devaddr 1 session_id 513
libusb:debug [enumerate_device] allocating new device for 2/1 (session 513)
libusb:debug [sysfs_scan_device] scan usb3
libusb:debug [sysfs_scan_device] bus=3 dev=1
libusb:debug [enumerate_device] busnum 3 devaddr 1 session_id 769
libusb:debug [enumerate_device] allocating new device for 3/1 (session 769)
libusb:debug [sysfs_scan_device] scan usb4
libusb:debug [sysfs_scan_device] bus=4 dev=1
libusb:debug [enumerate_device] busnum 4 devaddr 1 session_id 1025
libusb:debug [enumerate_device] allocating new device for 4/1 (session 1025)
libusb:debug [sysfs_scan_device] scan usb5
libusb:debug [sysfs_scan_device] bus=5 dev=1
libusb:debug [enumerate_device] busnum 5 devaddr 1 session_id 1281
libusb:debug [enumerate_device] allocating new device for 5/1 (session 1281)
libusb:debug [sysfs_scan_device] scan usb6
libusb:debug [sysfs_scan_device] bus=6 dev=1
libusb:debug [enumerate_device] busnum 6 devaddr 1 session_id 1537
libusb:debug [enumerate_device] allocating new device for 6/1 (session 1537)
libusb:debug [sysfs_scan_device] scan usb7
libusb:debug [sysfs_scan_device] bus=7 dev=1
libusb:debug [enumerate_device] busnum 7 devaddr 1 session_id 1793
libusb:debug [enumerate_device] allocating new device for 7/1 (session 1793)
libusb:debug [sysfs_scan_device] scan usb8
libusb:debug [sysfs_scan_device] bus=8 dev=1
libusb:debug [enumerate_device] busnum 8 devaddr 1 session_id 2049
libusb:debug [enumerate_device] allocating new device for 8/1 (session 2049)
libusb:debug [sysfs_scan_device] scan 1-4
libusb:debug [sysfs_scan_device] bus=1 dev=4
libusb:debug [enumerate_device] busnum 1 devaddr 4 session_id 260
libusb:debug [enumerate_device] allocating new device for 1/4 (session 260)
libusb:debug [discovered_devs_append] need to increase capacity
libusb:debug [sysfs_scan_device] scan 3-1
libusb:debug [sysfs_scan_device] bus=3 dev=2
libusb:debug [enumerate_device] busnum 3 devaddr 2 session_id 770
libusb:debug [enumerate_device] allocating new device for 3/2 (session 770)
libusb:debug [sysfs_scan_device] scan 3-2
libusb:debug [sysfs_scan_device] bus=3 dev=3
libusb:debug [enumerate_device] busnum 3 devaddr 3 session_id 771
libusb:debug [enumerate_device] allocating new device for 3/3 (session 771)
libusb:debug [sysfs_scan_device] scan 1-4.7
libusb:debug [sysfs_scan_device] bus=1 dev=56
libusb:debug [enumerate_device] busnum 1 devaddr 56 session_id 312
libusb:debug [enumerate_device] allocating new device for 1/56 (session 312)
libusb:debug [sysfs_scan_device] scan 1-4.5
libusb:debug [sysfs_scan_device] bus=1 dev=48
libusb:debug [enumerate_device] busnum 1 devaddr 48 session_id 304
libusb:debug [enumerate_device] allocating new device for 1/48 (session 304)
libusb:debug [sysfs_scan_device] scan 1-4.4
libusb:debug [sysfs_scan_device] bus=1 dev=55
libusb:debug [enumerate_device] busnum 1 devaddr 55 session_id 311
libusb:debug [enumerate_device] allocating new device for 1/55 (session 311)
libusb:debug [sysfs_scan_device] scan 1-4.1
libusb:debug [sysfs_scan_device] bus=1 dev=57
libusb:debug [enumerate_device] busnum 1 devaddr 57 session_id 313
libusb:debug [enumerate_device] allocating new device for 1/57 (session 313)
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_get_device_descriptor]
libusb:debug [libusb_open] open 1.57
libusb:debug [usbi_add_pollfd] add fd 6 events 4
libusb:debug [libusb_unref_device] destroy device 1.1
libusb:debug [libusb_unref_device] destroy device 2.1
libusb:debug [libusb_unref_device] destroy device 3.1
libusb:debug [libusb_unref_device] destroy device 4.1
libusb:debug [libusb_unref_device] destroy device 5.1
libusb:debug [libusb_unref_device] destroy device 6.1
libusb:debug [libusb_unref_device] destroy device 7.1
libusb:debug [libusb_unref_device] destroy device 8.1
libusb:debug [libusb_unref_device] destroy device 1.4
libusb:debug [libusb_unref_device] destroy device 3.2
libusb:debug [libusb_unref_device] destroy device 3.3
libusb:debug [libusb_unref_device] destroy device 1.56
libusb:debug [libusb_unref_device] destroy device 1.48
libusb:debug [libusb_unref_device] destroy device 1.55
find_and_claim_interface
libusb:debug [libusb_claim_interface] interface 0
find_and_claim_interface: couldn't claim interface
main: unable to claim interface
libusb:debug [libusb_exit]
libusb:warning [libusb_exit] application left some devices open
libusb:debug [usbi_remove_pollfd] remove fd 3
libusb:debug [usbi_remove_pollfd] remove fd 5
libusb:debug [libusb_exit] freeing default context

前缀有libusb的libusb库的debug信息,没有libusb前缀的是我的debug信息。
从前面看,已经成功的找到并且打开usb设备,执行到libusb_claim_interface就会出错。
libusb_claim_interface就两个参数,第一个是设备句柄,第二个是想要声明的接口数量。这两个参数并不是问题的根源。
libusb和kernel相关的代码走读了一下也看不出什么问题。
期待大家的回复。
发表于 2010-7-13 20:46:40 | 显示全部楼层
是不是你要claim的设备已经加载了内核驱动?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表