libusb--记录

1.下面的函数只有同步,没有异步的接口,不能被取消:

 

 * - Configuration activation (libusb_set_configuration())
 * - Interface/alternate setting activation (libusb_set_interface_alt_setting())
 * - Releasing of interfaces (libusb_release_interface())
 * - Clearing of halt/stall condition (libusb_clear_halt())
 * - Device resets (libusb_reset_device())

 

2.libusb_reset_device()重启的时候,如果有其它程序也在重启同一个设备,那么会出错;

 

3.No hotplugging,当设备被添加或者删除时,没有主动通知机制,计划在1.1添加;

 

   对于一个打开的设备,基本的断开处理如下:

   a.如果是正在处理传输,handle_events loop将会检测到设备断开,然后完成正在进行的传输,

       并返回LIBUSB_TRANSFER_NO_DEVICE状 态。

    b.许多函数,比如 libusb_set_configuration()将返回LIBUSB_ERROR_NO_DEVICE;

 

4.配置设备的告诫:

     a.如果设备已经在希望的配置下,用同样的配置值调用libusb_set_configuration()将引起设备重启。

     b.在其它程序或者驱动获得了设备的配置,那么此程序不能改变配置。

     c.如果希望的配置已经被激活,那么libusb也许不能执行一个设备重启。

  For example,
 *    take my USB keyboard with fingerprint reader: I'm interested in driving
 *    the fingerprint reader interface through libusb, but the kernel's
 *    USB-HID driver will almost always have claimed the keyboard interface.
 *    Because the kernel has claimed an interface, it is not even possible to
 *    perform the lightweight device reset, so libusb_set_configuration() will
 *    fail. (Luckily the device in question only has a single configuration.)

 

为了解决以上的问题,一个可能的解决方案是:

cfg = libusb_get_configuration(dev);
if (cfg != desired)
    libusb_set_configuration(dev, desired);

这有一个缺点,如果在get或者set配置后,其它的程序也许会改变配置,怎么办呢? 可以通过下面的方法解决。

1.设置希望的配置

2.获得接口

3.检查当前的配置是不是所要的配置。

 

 5. Early transfer completion

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值