设备崩溃后重新连接到设备

发布于 2024-12-26 02:00:35 字数 520 浏览 5 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断舍离 2025-01-02 02:00:35

您需要在设备上调用 open() - 这对于系统来说是新的。

You will need to call open() on the device - it is new for the system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文