Java Simple Serial Connector (jssc) ports not detected

I am using jSSC-2.6.0 in a cross-platform application. The returned port list on Windows computers (32/64-bit) is correct, but the MacOSX application (v10.6 and 10.7) does not return any serial devices. If I look at serial devices manually in the terminal ls /dev/tty.* , I can view three devices. Executing the following line from the jssc example file does not return anything on the same MAC computer:

String[] portNames = SerialPortList.getPortNames();

I can only see a whole bunch of devices, including those that are in the terminal, after use:

String[] portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("tty."));

The disadvantage is that it hangs on the machine for 10 seconds, and on the other machine (10.7) it does not respond after 30 seconds.

Is there a way to reliably connect to a serial device on a MAC using jssc?

+4
source share
1 answer

jSSC uses this regexp to list serial ports on a Mac: tty.(serial|usbserial|usbmodem).* If your device cannot be found with this regular expression, you must change it to get the name of your device.

The next important point is that jSSC tries to open the port and get the termios structure to identify the real serial device. In the described situation, I can offer to use only official and latent drivers. Port enumeration functions are very simple, try using several serial port terminals to test this problem on other software.

+3
source

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


All Articles