【发布时间】:2017-08-03 07:04:21
【问题描述】:
我正在尝试使用 libusb 与 CDC 设备通信。我测试的代码如下;
/* Initialize libusb
*/
rc = libusb_init(NULL);
if (rc < 0) {
fprintf(stderr, "Error initializing libusb: %s\n", libusb_error_name(rc));
exit(1);
}
/* Set debugging output to max level.
*/
libusb_set_debug(NULL, 3);
/* Look for a specific device and open it.
*/
devh = libusb_open_device_with_vid_pid(NULL, VENDOR_ID, PRODUCT_ID);
if (!devh) {
fprintf(stderr, "Error finding USB device\n");
goto out;
}
不是:我从https://github.com/tytouf/libusb-cdc-example/blob/master/cdc_example.c获取代码
我为 Windows 和 linux 构建了该项目。在 linux 中,程序按预期工作。设备已成功打开。但在 windows 中,libusb 无法打开设备。始终返回错误“UNKNOWN_ERROR”(错误代码为 0xFFFFFFFb)
可能是什么错误?
【问题讨论】:
-
你在windows上安装some sort of driver了吗?
-
感谢您的回复。是的,我安装了驱动程序,但问题仍然存在。此外,我可以从任何终端程序访问 CDC 设备。 Windows 成功枚举设备。
-
您使用的是什么 Windows 版本,您使用的是哪个编译器,您的程序的确切输出是什么?您可以尝试以管理员身份执行它吗?
-
我使用 Visual Studio 的编译器。我下载了 libusb-1.0 源代码并使用 CMake 编译(我的 Visual Studio 版本是 2017 社区版) Windows 版本是 Win7,我以管理员身份执行,没有任何变化