【问题标题】:Java: Serial Communication with USB port that is not listed as COM-portJava:与未列为 COM 端口的 USB 端口进行串行通信
【发布时间】:2021-05-07 16:40:32
【问题描述】:

我正在尝试与 USB 驱动的硬件建立串行通信。不幸的是,在列出的 COM 端口下的设备管理器中无法识别硬件。因此,它没有出现在我的列表中,我也不知道它的 COM 端口号。相反,该设备被列为另一种类型的硬件。

我怎样才能与它保持联系?

我目前正在使用以下代码打开我的 USB 端口。

    public ArrayList<String> getPorts() {
CommPortIdentifier serialPortId;
ArrayList<String> portID = new ArrayList<String>();
Enumeration enumComm = CommPortIdentifier.getPortIdentifiers();
while (enumComm.hasMoreElements()) {
    serialPortId = (CommPortIdentifier) enumComm.nextElement();
    if (serialPortId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
        String portString= new String(serialPortId.getName());
        portID.add(portString);
    }
}
return portID;
   }

【问题讨论】:

    标签: java serial-port usb communication


    【解决方案1】:

    我怎样才能与它保持联系?

    您需要将 java 绑定到硬件实际使用的任何驱动程序,例如 LibUSB 或 hidapi。

    【讨论】:

    • 非常感谢您的回复。 LibUSB 和 hidapi Java 工具是否支持与 USB 驱动程序的通信?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多