简体   繁体   English

找不到串口

[英]Unable to find serial ports

Using Rxtx API. 使用Rxtx API。

I am 100% sure there is a serial port available. 我100%肯定有可用的串行端口。 On Debian, I can see /dev/ttyUSB3 exists when the device is connected. 在Debian上,连接设备后,我可以看到/dev/ttyUSB3存在。

Tried running getPortIdentifiers() and got nothing when I tried iterating over the hashset 尝试运行getPortIdentifiers()并尝试遍历哈希集时一无所获

CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/ttyUSB3");

Also did not work. 也没有用。 I got: 我有:

Exception Caused by: gnu.io.NoSuchPortException 引起的异常:gnu.io.NoSuchPortException

What am I doing wrong? 我究竟做错了什么? I am fairly sure rxtx was set up correctly. 我相当确定rxtx设置正确。

The problem here is with how RXTX defines ports. 问题在于RXTX如何定义端口。 By default, it will only look for certain serial ports(on Linux, /dev/ttySX ). 默认情况下,它将仅查找某些串行端口(在Linux上为/dev/ttySX )。 There are several options you have to fix this: 您必须解决几个问题:

  1. Set the gnu.io.rxtx.SerialPorts property when you start Java(either on the command line, or through code. See the Rxtx documentation for more details) 在启动Java时设置gnu.io.rxtx.SerialPorts属性(在命令行或通过代码。有关更多详细信息,请参见Rxtx文档
  2. Use a different serial port library that lets you select serial ports manually. 使用不同的串行端口库,该库可让您手动选择串行端口。

For #2, the following are libraries that I know of: 对于#2,以下是我所知道的库:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM