Serial port with jSSC on Linux

I am trying to work with serial port in java with jSSC. My code is:

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

but it always returns an 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 anybody help me?

+4
source share
1 answer

I recently ran into the same problem, here's what I managed to find out.

The first thing you should check is that you have sufficient rights to access the tty * interface.

First, make sure your user is in a group dialout. If not, do

sudo adduser phil dialout

and then grant yourself read and write permissions to the exact port.

sudo chmod 666 /dev/ttyS0

After that I SerialPortList.getPortNames()must returnttyS0

+3
source

Source: https://habr.com/ru/post/1612369/


All Articles