0

我有一个应用程序可以在有或没有连接到机器的 USB CDC 设备的情况下运行。该设备被编程为以特定答案回答问题,因此我可以检测连接到哪个串行端口。问题是,我需要知道何时执行此检查。我不想创建一个线程来一遍又一遍地运行这个检查,所以我需要知道如何监听“设备连接”事件。我以前搜索过它,但也许我只是没有使用正确的关键词,所以任何帮助都会非常好。

Obs:我正在使用 Java 1.7 和 RXTX 库。

4

1 回答 1

1

I have the same problem and AFAIK there is no way to do this in a platform independent way. On linux one might do it as described here.

Anyway, in case your device is a USB/Serial converter, you will only get an event when the converter is (un)plugged, not when a device is attached to the converter itself.

于 2012-11-28T15:41:32.640 回答