OptolinkInterface.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:optolink 作者:
OptolinkInterface(String device, int timeout) throws Exception {

        // constructor with implicit open

        this.device = device;

        log.debug("Open TTY {} ...", this.device);
        portIdentifier = CommPortIdentifier.getPortIdentifier(this.device);

        if (portIdentifier.isCurrentlyOwned()) {
            log.error("TTY {} in use.", this.device);
            throw new IOException();
        }
        commPort = portIdentifier.open(this.getClass().getName(), timeout);
        if (commPort instanceof SerialPort) {
            SerialPort serialPort = (SerialPort) commPort;
            serialPort.setSerialPortParams(4800, SerialPort.DATABITS_8,
                    SerialPort.STOPBITS_2, SerialPort.PARITY_EVEN);

            input = serialPort.getInputStream();
            output = serialPort.getOutputStream();
            commPort.enableReceiveTimeout(timeout); // Reading Time-Out
        }
        log.debug("TTY {} opened", this.device);
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号