简体   繁体   English

Java简单串行连接器(jssc)未检测到端口

[英]Java Simple Serial Connector (jssc) no ports detected

I'm using jSSC-2.6.0 in a cross-platform application. 我在跨平台应用程序中使用jSSC-2.6.0。 The returned portlist on Windows machines (32/64bit) are correct, however the MacOSX (v10.6 and 10.7) application does not return any serial devices. Windows计算机(32/64位)上返回的端口列表是正确的,但MacOSX(v10.6和10.7)应用程序不返回任何串行设备。 If I view the serial devices manually in terminal ls /dev/tty.* , I can view three devices. 如果我在终端ls /dev/tty.*手动查看串口设备,我可以查看三个设备。 Running the following line from the jssc example file returns nothing on that same MAC machine: 从jssc示例文件运行以下行不会在同一MAC机器上返回任何内容:

String[] portNames = SerialPortList.getPortNames();

I can only see a whole bunch of devices, including the ones in the terminal, after I use: 我使用后,我只能看到一大堆设备,包括终端设备:

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

A drawback is that it hangs the machine for 10 seconds and on the other machine (10.7) it does not respond after 30 seconds. 缺点是它将机器挂起10秒钟,而在另一台机器上(10.7)它在30秒后没有响应。

Is there a way to reliably connect to a serial device on the MAC using jssc? 有没有办法使用jssc可靠地连接到MAC上的串行设备?

jSSC use this regexp for listing serial ports on Mac: tty.(serial|usbserial|usbmodem).* If your device cannot be found with this regexp you should change it for getting your device name. jSSC使用此正则regexp列出Mac上的串行端口: tty.(serial|usbserial|usbmodem).*如果使用此正则表达式找不到您的设备,则应更改它以获取设备名称。

The next important thing is that jSSC try to open port and get termios structure for identify the real serial device. 下一个重要的事情是jSSC尝试打开端口并获取termios结构以识别真正的串行设备。 In described situation I can suggest to use only official and latests drivers. 在描述的情况下,我建议只使用官方和最晚的司机。 Port listing functionality is realy simple, try to use some serial port terminal for checking this issue on another software. 端口列表功能非常简单,尝试使用某些串口终端在另一个软件上检查此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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