`libusb_attach_kernel_driver` not working
`libusb_attach_kernel_driver` not working
我有一个问题,干净地关闭我的Linux应用程序,使用libusb
(内核不回收接口):
int rc;
rc = libusb_reset_device(handle_);
if (rc < 0) {
cerr << "Error resetting the device: " << libusb_error_name(rc);
}
for (int ifnum = 0; ifnum < 2; ifnum++) {
rc = libusb_release_interface(handle_, ifnum);
if (rc < 0) {
cerr << "Error releasing interface: " << libusb_error_name(rc);
}
if (libusb_kernel_driver_active(handle_, ifnum)) {
cerr << "Reattaching CDC ACM kernel driver.";
rc = libusb_attach_kernel_driver(handle_, ifnum);
if (rc < 0) {
cerr << "Error reattaching CDC ACM kernel driver: " << libusb_error_name(rc);
}
}
}
libusb_close(handle_);
libusb_exit(NULL);
问题是重新连接内核驱动程序不工作。实际上,libusb_kernel_driver_active
不返回1,但即使我注释掉它并始终调用libusb_attach_kernel_driver
,我也永远不会返回我的/dev/ttyACM0
设备。在本例中我得到LIBUSB_ERROR_NOT_FOUND
我已经调试了linux cdc-acm驱动附加代码,并找到了问题的根本原因。重新连接不工作的原因是我正在声明CDC ACM设备的控制和数据接口。如果我只分离/附加控制接口(ifnum == 0),那么一切都按预期工作。
相关文章:
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 使用JsonCpp将数据返回到带有pybind11的python会在python调用中产生Symbol not foun
- OpenCV Android C++ imwrite not found
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 使用单词"not"作为C ++类的名称会导致VS2019错误
- 错误"Could not find Boost"(缺少:上下文标头)
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- Is !NaN not a NaN?
- 为什么我会" void value not ignored as it ought to be"?
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- Directx 11 - CompileFromFile() is not compiling
- 方法错误"not all control paths return a value"和方法不返回值
- Centos7 g++ "to_string is not in a member of std"
- 将系数存储在头文件的数组中("does not name a type"错误)
- QGraphicsItems not showing up QGraphicsScene
- 在调试模式下引发C++ "deque iterator not dereferencable"异常
- QSqlDatabase: QMYSQL driver not loadedQSqlDatabase: availabl
- CUDA 内核导致"display driver not responding",增加了 4 行