5

I'm trying to work with serial port in java with jSSC. My code:

import jssc.SerialPortList;
....
String[] ports = SerialPortList.getPortNames();

but it always return empty array.

brut@brut-Z97-D3H:~$ dmesg | grep tty
[    0.000000] console [tty0] enabled
[    0.957537] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A

Can anyone help me?

brut
  • 327
  • 1
  • 11

1 Answers1

7

I've faced the same issue recently, here's what I've managed to find out.

The first thing you should check is whether you have enough rights to access tty* interface.

Firstly, make sure your user is in dialout group. If not, execute

sudo adduser phil dialout

and then give yourself rights to read-write to the exact port.

sudo chmod 666 /dev/ttyS0

After that SerialPortList.getPortNames() should return ttyS0

phil_g
  • 516
  • 6
  • 13