【问题标题】:How to check if kernel driver is attached with libusb-0.1?如何检查内核驱动程序是否附加了 libusb-0.1?
【发布时间】:2013-07-31 05:05:54
【问题描述】:

在 libusb-1.0 中,可以使用libusb_kernel_driver_active

if (libusb_kernel_driver_active(dev_handle, 0) == 1) { //find out if kernel driver is attached
        cout<<"Kernel Driver Active"<<endl;
        if(libusb_detach_kernel_driver(dev_handle, 0) == 0) //detach it
            cout<<"Kernel Driver Detached!"<<endl;
    }

如何使用 libusb-0.1 进行检查?

【问题讨论】:

    标签: libusb libusb-1.0


    【解决方案1】:

    对于 libusb-compat,您可以使用 usb_get_driver_np:

    API_EXPORTED int usb_get_driver_np(usb_dev_handle *dev, int interface,
        char *name, unsigned int namelen)
    {
        int r = libusb_kernel_driver_active(dev->handle, interface);
        if (r == 1) {
            /* libusb-1.0 doesn't expose driver name, so fill in a dummy value */
            snprintf(name, namelen, "dummy");
            return 0;
        } else if (r == 0) {
            return -(errno=ENODATA);
        } else {
            return compat_err(r);
        }
    }
    

    【讨论】:

    • 而且,我想,你应该总是检查 [this][1]libusb.sourceforge.net/doc/functions.html,然后再对有关 libusb-0.1 的东西挠头。尽你所能去尝试总是好的,然后去 SO 这样的地方。这将帮助您实际解决您自己的问题。尽管尝试了您所知道的,如果您无法通过,欢迎来到 SO!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 2014-02-05
    • 2010-09-11
    • 1970-01-01
    相关资源
    最近更新 更多