设置 USB 配置失败
我正在尝试使用 libusb 与 USB 设备通信,但我觉得我在比赛的第一段就绊倒了。 我确切地知道我需要与哪些端点交谈等,但我什至无法做到这一点。 我本质上是:
usb_device *dev = ...; // opened from get_busses()
usb_set_configuration(dev, dev->config[0].bConfigurationValue); // bConfigVal = 1
现在,我可以在调试模式下查看设备信息,并且我知道当前配置为 0(未初始化/重启后),并且恰好有 1 个有效配置,其配置编号为 1。但是当我将配置设置为 1 时,我得到的返回值是 -22,它(通过字符串生成器传递)转换为“windows api 错误:参数错误。
我找不到其他人有类似的问题,这看起来是一件很简单的事情——我什至不能声明接口,或设置替代接口,或类似的东西,因为我必须首先设置配置(如果有的话?重要的是:这是在 WinXP 上)
I'm trying to talk to a USB device using libusb, but I feel like I'm tripping up on the first leg of the race. I know precisely what endpoints I need to talk to, etc., but I can't even get that far. I have, in essence:
usb_device *dev = ...; // opened from get_busses()
usb_set_configuration(dev, dev->config[0].bConfigurationValue); // bConfigVal = 1
Now, I can look at the device information in debug mode and I know that the current configuration is 0 (uninitialized / just after restart), and there's exactly 1 valid configuration, which has a configuration number of 1. But when I set the config to 1, I get a return value of -22, which (passed through the stringifier) translates to "windows api error: bad parameter.
I haven't been able to find other people having a similar problem, and it seems like such a simple thing to do -- I can't even claim the interface, or set the alt-interface, or anything like that, because I have to set the configuration first. What am I missing? (if it matters: this is on WinXP)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 libusb-win32\src\driver\set_configuration.c,返回 STATUS_INVALID_PARAMETER 的原因似乎有很多不同。
使用
libusb_set_debug
(从用户模式应用程序)设置详细调试级别,然后运行 Sysinternals DebugView 查看驱动程序的错误消息。 希望您能找到有关set_configuration
调用失败原因的线索。Looking at libusb-win32\src\driver\set_configuration.c, there seem to be a bunch of different reasons for returning
STATUS_INVALID_PARAMETER
.Use
libusb_set_debug
(from your user mode application) to set verbose debug level, then run Sysinternals DebugView to see the driver's error messages. Hopefully you'd see a clue as to why yourset_configuration
call fails.