简体   繁体   English

CommPortIdentifier.getPortIdentifiers() RXTX 未列出所有端口

[英]CommPortIdentifier.getPortIdentifiers() RXTX not listing all ports

I'm trying to first of all list ports on Ubuntu 14.04 LTS but not all ports are detected, it only displays tty.我首先尝试列出 Ubuntu 14.04 LTS 上的所有端口,但并未检测到所有端口,它仅显示 tty。 I want to access the hidraw one, see below.我想访问 hidraw 一个,见下文。

I have read/write permission on the lock file for everyone.我对每个人的锁定文件都有读/写权限。

  • File RXTXcomm.jar should go under JDKDIR/jre/lib/ext/文件 RXTXcomm.jar 应该在 JDKDIR/jre/lib/ext/ 下
  • The necessary library (eg. for Linux 32bit, the librxtxSerial.so) should go under JDKDIR/jre/bin/必要的库(例如,对于 Linux 32 位,librxtxSerial.so)应该在 JDKDIR/jre/bin/ 下
  • librxtxSerial.so in lib/bin also lib/bin 中的 librxtxSerial.so 也是

The librxtxSerial.so is for x86_64 (my computer: Intel i7 4790k Running Ubuntu 64 bit) librxtxSerial.so 适用于 x86_64(我的电脑:Intel i7 4790k 运行 Ubuntu 64 位)

dpkg --print-architecture
amd64

uname -a 
Linux KrantzUbuntu 3.13.0-65-generic #106-Ubuntu SMP Fri Oct 222:08:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

When I list connected ports in the terminal I get those:当我在终端中列出连接的端口时,我得到了这些:

/dev/hidraw4 - Broadcom_Corp_BCM20702A0_54271EFCD756
/dev/input/event14 - Broadcom_Corp_BCM20702A0_54271EFCD756
/dev/input/mouse1 - Broadcom_Corp_BCM20702A0_54271EFCD756
/dev/input/event2 - Logitech_Gaming_Mouse_G400
/dev/input/mouse0 - Logitech_Gaming_Mouse_G400
/dev/hidraw0 - Logitech_Gaming_Mouse_G400
/dev/usb/hiddev0 - Logitech_Gaming_Mouse_G400
/dev/hidraw1 - Logitech_Gaming_Mouse_G400
/dev/input/event3 - CM_Storm_Quickfire_TKL_6keys
/dev/hidraw2 - CM_Storm_Quickfire_TKL_6keys
/dev/input/event4 - CM_Storm_Quickfire_TKL_6keys
/dev/hidraw3 - CM_Storm_Quickfire_TKL_6keys

The on I want to use later on is the /dev/hidraw4 one, which is a Bluetooth mobile phone.后面我想用的那个是/dev/hidraw4,是蓝牙手机。

I have recompiled the RXTXCommDriver class search for more ports on Linux and added:我重新编译了 RXTXCommDriver 类在 Linux 上搜索更多端口并添加:

if(osName.equals("Linux"))
                {
                    String[] Temp = {
                    "sr",
                    "hidraw",
                    "usb",
                    "input",
                    "sr0",
                    "ttyS", // linux Serial Ports
                    "ttySA", // for the IPAQs
                    "ttyUSB", // for USB frobs
                    "rfcomm",       // bluetooth serial device
                    "ttyircomm", // linux IrCommdevices (IrDA serial emu)
                    };
                    CandidatePortPrefixes=Temp;
                }

But still doesn't list hidraw.但仍然没有列出hidraw。

Try out these steps (I do hope that they'll help you fix your problem):尝试以下步骤(我希望它们能帮助您解决问题):

  • Check if the .so-file is on your classpath.检查 .so 文件是否在您的类路径中。 You can download prebuilt binaries, 32-bit and 64-bit.您可以下载 32 位和 64 位预构建的二进制文件。 Links can be found in this thread: RXTX can't list port on ubuntu链接可以在这个线程中找到: RXTX can't list port on ubuntu
  • Verify that you actually do have the required permissions (example for USB0):验证您确实拥有所需的权限(例如 USB0):

     sudo chmod 666 /dev/ttyUSB0

    Note: This will only be active until you reboot your computer, so in case it fixes your problem you'll probably want to create an udev rule (Google: udev usb permissions ) to permanently take care of that problem.注意:这只会在您重新启动计算机之前处于活动状态,因此如果它解决了您的问题,您可能需要创建一个 udev 规则(谷歌: udev usb 权限)来永久解决该问题。

I'm pretty sure that you've found this snippet already, but just in case you didn't I'll leave it here: Discovering comm ports我很确定你已经找到了这个片段,但万一你没有找到,我会把它留在这里:发现通信端口

Sources (just in case anyone wants to read the full articles/questions/answers):来源(以防万一有人想阅读完整的文章/问题/答案):

RXTX can't list port on ubuntu RXTX 无法在 ubuntu 上列出端口

CommPortIdentifier.getPortIdentifiers with zero ports on Linux Linux 上具有零端口的 CommPortIdentifier.getPortIdentifiers

ttyUSB0 permission changes after restart 重启后 ttyUSB0 权限更改

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

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