简体   繁体   English

在Linux上具有零端口的CommPortIdentifier.getPortIdentifiers

[英]CommPortIdentifier.getPortIdentifiers with zero ports on Linux

i am trying to connect serial port on ubuntu. 我正在尝试在ubuntu上连接串行端口。 However, It doesn't work for me. 但是,它对我不起作用。 I succesfully run the same project on Windows just with different drivers. 我可以使用不同的驱动程序在Windows上成功运行同一项目。 The problem is that I can't load any ports while I am using this: 问题是我在使用此端口时无法加载任何端口:

CommPortIdentifier.getPortIdentifiers(); CommPortIdentifier.getPortIdentifiers(); // i am using rxtx 2.1.7 //我正在使用rxtx 2.1.7

It always return zero ports. 它总是返回零端口。 I would like to use port ttyS0 whichworks great with minicon so i am sure that port is not blocked and the machine is not broken. 我想使用端口ttyS0,该端口可与minicon一起很好地工作,因此我确定端口未阻塞且机器未损坏。

Anyone has a reason for this ? 有人对此有理由吗?

It was just becouse low priviligies. 这只是因为特权低。 I had to add myself to a group which is supposed to work with ttyS0. 我必须将自己添加到应该与ttyS0一起使用的组中。

if nothing helps, you should consider to add this line to your java code: 如果没有帮助,则应考虑将此行添加到您的java代码中:

System.setProperty("gnu.io.rxtx.SerialPorts", "/dev/yourtty");

did it for me. 为我做了。 (Only if you work with the RXTX library) (仅当您使用RXTX库时)

I used this command 我用这个命令

sudo chmod 666 /dev/ttyUSB0 须藤chmod 666 / dev / ttyUSB0

I had the same problem and it worked the moment after I used this command. 我遇到了同样的问题,并且在使用此命令后立即起作用。 Like Smolda said, it is a permission problem. 就像Smolda所说的,这是一个许可问题。

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

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