设备崩溃后重新连接到设备
我在使用 libusb-java 和一些自制设备时遇到以下问题。 此类设备可能会因消耗大量电量而与 USB 端口断开连接(例如:我有一个 USB-LED 灯,有时需要超过 500mA 的电流)。 在这种情况下,USB 控制器将重置设备,设备将再次正常启动。
现在,除了尝试在每个异常时重新初始化设备之外,我无法真正检测到这样的问题。但这不起作用...
在每个异常上,我再次调用我的 init 方法,如下所示:
private void initDevice() {
USB.init();
this.dev = USB.getDevice(idVendor, idProduct);
}
问题是,它运行没有任何问题,但是当我想发送新数据时,我收到此错误消息:
LibusbJava.controlMsg: error sending control message: Protocol error
如何我可以重新初始化设备吗?我是否需要重置总线或其他什么?
I have the following problem with the libusb-java and some self-made devices.
It could happen that such a device disconnects from the USB Port because it drains to much power (as an example: i have a USB-LED Light which needs sometimes more than 500mA).
In this case the USB Controller will reset the device and the device will startup normaly again.
Now i cant really detect such a problem except for trying to reinit the device on every Exception. But thats not working...
On Every Exception i call my init Method again, which looks like this:
private void initDevice() {
USB.init();
this.dev = USB.getDevice(idVendor, idProduct);
}
The Problem with that is, this runs without any problem, but the i get this error message when i want to send new data:
LibusbJava.controlMsg: error sending control message: Protocol error
How do i can reinit the device? Do i have to reset the bus or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在设备上调用
open()
- 这对于系统来说是新的。You will need to call
open()
on the device - it is new for the system.