简体   繁体   中英

CommPortIdentifier.getPortIdentifiers with zero ports on Linux

i am trying to connect serial port on ubuntu. However, It doesn't work for me. I succesfully run the same project on Windows just with different drivers. The problem is that I can't load any ports while I am using this:

CommPortIdentifier.getPortIdentifiers(); // i am using 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.

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.

if nothing helps, you should consider to add this line to your java code:

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

did it for me. (Only if you work with the RXTX library)

I used this command

sudo 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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