3

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 ?

Smolda
  • 882
  • 5
  • 13
  • 34

3 Answers3

3

It was just becouse low priviligies. I had to add myself to a group which is supposed to work with ttyS0.

Smolda
  • 882
  • 5
  • 13
  • 34
3

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.

3

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)

rome
  • 476
  • 1
  • 9
  • 19
  • 1
    After first checking the accepted answer, It didn't work for me. After another hour of investigation, it seems this is a bug in RXTX2.2 which requires to set this gnu.io.rxtx.SerialPorts property - see also https://bugs.launchpad.net/ubuntu/+source/rxtx/+bug/367833 – Christoph Bimminger Aug 27 '18 at 19:16