RXTX不能列出或在Windows 7 64位找到端口端口、RXTX、Windows

2023-09-08 10:26:59 作者:“自由的味道更像孤独”

早上好,

我在使用问题/或Windows 7 64位安装RXTX。我曾与它previously在86赢得XP系统,也没有问题。由于重新安装这个新的系统由于某种原因RXTX无法找到任何任何端口。我试过RXTX安装,云Hopper的64位机库,并删除所有RXTX文件,并从头开始。 RXTXcomm.jar被发现,我可以浏览NetBeans中的包但执行似乎被打破还是没有找到。

在执行时,该线路出现故障时,每次:

  COMPORT =COM1;
端口ID = CommPortIdentifier.getPortIdentifier(相称);
 

和抛出一个NoSuchPortException。

使用此产生什么清单的串行端口。

 枚举端口= CommPortIdentifier.getPortIdentifiers();
字符串portArray [] = NULL;
而(ports.hasMoreElements()){
    CommPortIdentifier端口=(CommPortIdentifier)ports.nextElement();
    的System.out.println(port.getName());
}
 

我检查串行端口可用,因此在这一点上我想知道,如果本机库只是打破了Windows 7的64位。

有没有人成功地使用RXTX 2.2 $ P $ windows下的P2 7 64位?

犯规code在构造函数部分:

 公共SerialControl(字符串名称,字符串相称,INT波特率,数据位诠释,串奇偶校验,停止位双)抛出异常{
    INT停止= 0;
    int数据为0;
    INT PAR = 0;

    this.name =名称;

    //完整性检查和跨pretation
    如果(波特率> 115200 ||波特率< 300){
        通信System.err.println(名称+:构造函数():无效的波特率+波特率);
        抛出新的异常(无效的波特率,+波特率);
    }

    如果(数据位> = 5&安培;&安培;数据位与所述; = 8){
        开关(数据位){
            壳体5:
                数据= SerialPort.DATABITS_5;
                打破;
            情况6:
                数据= SerialPort.DATABITS_6;
                打破;
            案例7:
                数据= SerialPort.DATABITS_7;
                打破;
            案例8:
                数据= SerialPort.DATABITS_8;
                打破;
            默认:
                通信System.err.println(名称+:构造函数():无效的数据位,交换+数据位);
                抛出新的异常(无效数据位,交换+数据位);
        }
    } 其他 {
        抛出新的异常(无效数据位=+数据位);
    }

    如果(停止位> = 1.0&安培;&安培;停止位&其中; = 2.0){

        如果(停止位== 1.0){
            停止= SerialPort.STOPBITS_1;
        }否则,如果(停止位== 1.5){
            停止= SerialPort.STOPBITS_1_5;
        }否则,如果(停止位== 2.0){
            停止= SerialPort.STOPBITS_2;
        } 其他 {
            通信System.err.println(名称+:构造函数():无效的停止位,切换+停止位);
            抛出新的异常(无效的停止位,切换+停止位);
        }
    } 其他 {
        通信System.err.println(名称+:构造函数():无效的停止位,切换+停止位);
        抛出新的异常(无效停止位+停止位);
    }

    开关(奇偶校验){
        案S:
            PAR = SerialPort.PARITY_SPACE;
            打破;
        案E:
            PAR = SerialPort.PARITY_EVEN;
            打破;
        案M:
            PAR = SerialPort.PARITY_MARK;
            打破;
        案O:
            PAR = SerialPort.PARITY_ODD;
            打破;
        案N:
            PAR = SerialPort.PARITY_NONE;
            打破;
        默认:
            通信System.err.println(名称+:构造函数():无效的奇偶校验,切换+奇偶校验);
            抛出新的异常(无效奇偶校验,切换+奇偶校验);
    }

    // Inits
    //试图找到指定的端口
    尝试 {
        端口ID = CommPortIdentifier.getPortIdentifier(相称);
    }赶上(例外五){
        通信System.err.println(名称+:构造函数():没有这样的端口\+ COMPORT +\);
        e.printStackTrace();
        扔ê;
    }

    //打开的端口
    尝试 {
        的SerialPort =(的SerialPort)portId.open(用户端口,2000年);
    }赶上(PortInUseException E){
        通信System.err.println(名称+:构造函数():无法打开端口+相称);
        扔ê;
    }

    //取得输入流
    尝试 {
        的InputStream = serialPort.getInputStream();
    }赶上(IOException异常E){
        通信System.err.println(名称+:构造函数():无法获取输入流+相称);
        扔ê;
    }

    //设置串口参数,无流量控制
    尝试 {
        serialPort.setSerialPortParams(波特率,数据,停止,标准杆);
        serialPort.setDTR(假);
        serialPort.setRTS(假);
    }赶上(UnsupportedCommOperationException E){
        通信System.err.println(名称+:构造函数():初始化错误+相称);
        扔ê;
    }
}
 
WIN7 64位 illustrator cs6 应用程序无法正常启动0xc000007b

解决方案

我得到了同样的问题。我使用Eclipse作为IDE进行编程,我发现在官方的wiki这种替代配置:

复制RXTXcomm.jar到项目的lib目录 在导航包浏览器到lib文件夹,右键单击RXTXcomm.jar |构建路径|加入内置路径 复制rxtxSerial.dll和rxtxParallel.dll文件到你的项目的根目录 在运行|运行配置| Classpath选项卡|用户入口|高级|添加文件夹,选择你的项目的根文件夹 这应该是滥竽充数的Eclipse下运行,部署一个可运行的罐子时,只需确保DLL是在同一个文件夹中的jar(JVM假定它的类路径)

(这是我的第一个答案,我不知道我是否允许张贴一个外部链接,但五步来的,从http://rxtx.qbang.org/wiki/index.php/Using_RXTX_In_Eclipse )

希望它能帮助!

Good morning,

I'm having issues using/or installing rxtx on windows 7 64 bits. I worked with it previously on a x86 win XP system and had no issues. Since reinstalling to this new system for some reason rxtx is unable to locate any ports whatsoever. I've tried the rxtx install, Cloud Hopper's 64 bit native library and deleting all rxtx files and starting from scratch. RXTXcomm.jar is found and I can browse the packages in NetBeans but the implementation seems to be broken or not found.

This line fails when executing, every time :

comPort = "COM1";
portId = CommPortIdentifier.getPortIdentifier(comPort);

and throws a NoSuchPortException.

Listing the serial ports using this produces nothing.

Enumeration ports = CommPortIdentifier.getPortIdentifiers();
String portArray[] = null;
while (ports.hasMoreElements()) {
    CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
    System.out.println(port.getName());
} 

I've checked the serial ports are available so at this point I'm wondering if the native libraries are simply broken for windows 7 64 bits.

Has anyone successfully used RXTX 2.2pre2 under windows 7 64 bits?

Offending code section in constructor :

public SerialControl(String name, String comPort, int baudrate, int databits, String     parity, double stopbits) throws Exception {
    int stop = 0;
    int data = 0;
    int par = 0;

    this.name=name;

    // Sanity checks and interpretation
    if (baudrate > 115200 || baudrate < 300) {
        System.err.println(name+": constructor(): Invalid baudrate "+baudrate);
        throw new Exception("Invalid baudrate, " + baudrate);
    }

    if (databits >= 5 && databits <= 8) {
        switch (databits) {
            case 5:
                data = SerialPort.DATABITS_5;
                break;
            case 6:
                data = SerialPort.DATABITS_6;
                break;
            case 7:
                data = SerialPort.DATABITS_7;
                break;
            case 8:
                data = SerialPort.DATABITS_8;
                break;
            default:
                System.err.println(name+": constructor(): Invalid data bits, switched " + databits);
                throw new Exception("Invalid data bits, switched " + databits);
        }
    } else {
        throw new Exception("Invalid data bits=" + databits);
    }

    if (stopbits >= 1.0 && stopbits <= 2.0) {

        if (stopbits == 1.0) {
            stop = SerialPort.STOPBITS_1;
        } else if (stopbits == 1.5) {
            stop = SerialPort.STOPBITS_1_5;
        } else if (stopbits == 2.0) {
            stop = SerialPort.STOPBITS_2;
        } else {
            System.err.println(name+": constructor(): Invalid stop bits, switched " + stopbits);
            throw new Exception("Invalid stop bits, switched " + stopbits);
        }
    } else {
        System.err.println(name+": constructor(): Invalid stop bits, switched " + stopbits);
        throw new Exception("Invalid stop bits " + stopbits);
    }

    switch (parity) {
        case "S":
            par = SerialPort.PARITY_SPACE;
            break;
        case "E":
            par = SerialPort.PARITY_EVEN;
            break;
        case "M":
            par = SerialPort.PARITY_MARK;
            break;
        case "O":
            par = SerialPort.PARITY_ODD;
            break;
        case "N":
            par = SerialPort.PARITY_NONE;
            break;
        default:
            System.err.println(name+": constructor(): Invalid parity, switched " + parity);
            throw new Exception("Invalid parity, switched " + parity);
    }

    // Inits
    // Try to find the port specified
    try {
        portId = CommPortIdentifier.getPortIdentifier(comPort);
    } catch (Exception e) {
        System.err.println(name+": constructor(): No such port \"" + comPort+"\"");
        e.printStackTrace();
        throw e;
    }

    // Open the port
    try {
        serialPort = (SerialPort) portId.open("User Port", 2000);
    } catch (PortInUseException e) {
        System.err.println(name+": constructor(): Could not open port " + comPort);
        throw e;
    }

    // Grab the input stream
    try {
        inputStream = serialPort.getInputStream();
    } catch (IOException e) {
        System.err.println(name+": constructor(): Could not get input stream for " + comPort);
        throw e;
    }

    // Set the serial port parameters, no flow control
    try {
        serialPort.setSerialPortParams(baudrate, data, stop, par);
        serialPort.setDTR(false);
        serialPort.setRTS(false);
    } catch (UnsupportedCommOperationException e) {
        System.err.println(name+": constructor(): Error initializing " + comPort);
        throw e;
    }
}

解决方案

I got the same problem. I use Eclipse as IDE for programming and i found this alternative configuration in the official wiki:

Copy RXTXcomm.jar to the lib directory of your project Navigate your package explorer to the lib folder, right click on RXTXcomm.jar | Build Path | Add to built path Copy rxtxSerial.dll and rxtxParallel.dll files to the root directory of your project Under Run | Run configurations | Classpath tab | User entries | Advanced | Add folder, choose the root folder of your project This should be enough just to run it under Eclipse, when deploying a runnable jar, just make sure the dlls are on the same folder as the jar (JVM assumes it for classpath)

(It's my first answer, i don't know if i'm allowed to post an external link, but the five step come's from http://rxtx.qbang.org/wiki/index.php/Using_RXTX_In_Eclipse )

Hope it help !