Package gnu.io

Examples of gnu.io.SerialPort


        long connectTimeout = getConnectTimeoutMillis();
        if (connectTimeout > Integer.MAX_VALUE) {
            connectTimeout = Integer.MAX_VALUE;
        }

        SerialPort serialPort = (SerialPort) portId.open(
                user, (int) connectTimeout);

        serialPort.setSerialPortParams(portAddress.getBauds(), portAddress
                .getDataBitsForRXTX(), portAddress.getStopBitsForRXTX(),
                portAddress.getParityForRXTX());

        serialPort.setFlowControlMode(portAddress.getFLowControlForRXTX());

        serialPort.notifyOnDataAvailable(true);

        if (config.isLowLatency()) {
            serialPort.setLowLatency();
        }

        serialPort.setInputBufferSize(config.getInputBufferSize());

        if (config.getReceiveThreshold() >= 0) {
            serialPort.enableReceiveThreshold(config.getReceiveThreshold());
        } else {
            serialPort.disableReceiveThreshold();
        }

        return serialPort;
    }
View Full Code Here


    } else {
      CommPort commPort = portIdentifier.open(this.getClass().getName(),
          TIME_OUT);

      if (commPort instanceof SerialPort) {
        SerialPort serialPort = (SerialPort) commPort;
        serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
            SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

        inStream = serialPort.getInputStream();
        outStream = serialPort.getOutputStream();

        new SerialReceiver().start();

        /*serialPort.addEventListener(this);
        serialPort.notifyOnDataAvailable(true);*/
 
View Full Code Here

                    try {
                        if (log.isDebugEnabled()) {
                            log.debug("Serial port found : " + portId.getName());
                        }

                        SerialPort serialPort = initializePort("Apache MINA", portId, portAddress);

                        ConnectFuture future = new DefaultConnectFuture();
                        SerialSessionImpl session = new SerialSessionImpl(this, getListeners(), portAddress, serialPort);
                        initSession(session, future, sessionInitializer);
                        session.start();
View Full Code Here

        long connectTimeout = getConnectTimeoutMillis();
        if (connectTimeout > Integer.MAX_VALUE) {
            connectTimeout = Integer.MAX_VALUE;
        }

        SerialPort serialPort = (SerialPort) portId.open(user, (int) connectTimeout);

        serialPort.setSerialPortParams(portAddress.getBauds(), portAddress.getDataBitsForRXTX(),
                portAddress.getStopBitsForRXTX(), portAddress.getParityForRXTX());

        serialPort.setFlowControlMode(portAddress.getFLowControlForRXTX());

        serialPort.notifyOnDataAvailable(true);

        if (config.isLowLatency()) {
            serialPort.setLowLatency();
        }

        serialPort.setInputBufferSize(config.getInputBufferSize());
        serialPort.setOutputBufferSize(config.getOutputBufferSize());

        if (config.getReceiveThreshold() >= 0) {
            serialPort.enableReceiveThreshold(config.getReceiveThreshold());
        } else {
            serialPort.disableReceiveThreshold();
        }

        return serialPort;
    }
View Full Code Here

            {
              success=0;
              break;
            }
          CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(porta);
            SerialPort sp = (SerialPort)portId.open("Sms_GSM", 0);
            sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            sp.setFlowControlMode(sp.FLOWCONTROL_NONE);

            in = sp.getInputStream();
            out = sp.getOutputStream();

            // modem reset
            sendAndRecv("+++AT", 30);       // delay for 20 sec/10
            sendAndRecv("AT&F", 30);
            sendAndRecv("ATE0", 30);        // echo off
View Full Code Here

  SerialToGsm(String porta) {
        try {
//            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("serial0");
            portnum=porta;
          CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(porta);
            SerialPort sp = (SerialPort)portId.open("Sms_GSM", 0);
            sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            sp.setFlowControlMode(sp.FLOWCONTROL_NONE);

            in = sp.getInputStream();
            out = sp.getOutputStream();

            // modem reset
            sendAndRecv("+++AT", 30);       // delay for 20 sec/10
            sendAndRecv("AT&F", 30);
            sendAndRecv("ATE0", 30);        // echo off
View Full Code Here

                            log
                                    .debug("Serial port found : "
                                            + portId.getName());
                        }

                        SerialPort serialPort = initializePort("Apache MINA",
                                portId, portAddress);

                        ConnectFuture future = new DefaultConnectFuture();
                        SerialSessionImpl session = new SerialSessionImpl(
                                this, getListeners(), portAddress, serialPort);
View Full Code Here

        long connectTimeout = getConnectTimeoutMillis();
        if (connectTimeout > Integer.MAX_VALUE) {
            connectTimeout = Integer.MAX_VALUE;
        }

        SerialPort serialPort = (SerialPort) portId.open(
                user, (int) connectTimeout);

        serialPort.setSerialPortParams(portAddress.getBauds(), portAddress
                .getDataBitsForRXTX(), portAddress.getStopBitsForRXTX(),
                portAddress.getParityForRXTX());

        serialPort.setFlowControlMode(portAddress.getFLowControlForRXTX());

        serialPort.notifyOnDataAvailable(true);

        if (config.isLowLatency()) {
            serialPort.setLowLatency();
        }

        serialPort.setInputBufferSize(config.getInputBufferSize());
        serialPort.setOutputBufferSize(config.getOutputBufferSize());

        if (config.getReceiveThreshold() >= 0) {
            serialPort.enableReceiveThreshold(config.getReceiveThreshold());
        } else {
            serialPort.disableReceiveThreshold();
        }

        return serialPort;
    }
View Full Code Here

        if (portIdentifier.isCurrentlyOwned()) {
            throw new Exception(Localization.getString("connection.exception.inuse"));
        } else {
            this.commPort = portIdentifier.open(this.getClass().getName(), 2000);

            SerialPort serialPort = (SerialPort) this.commPort;
            serialPort.setSerialPortParams(baud,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);

            this.in = serialPort.getInputStream();
            this.out = serialPort.getOutputStream();

            serialPort.addEventListener(this);
            serialPort.notifyOnDataAvailable(true)
            serialPort.notifyOnBreakInterrupt(true);

            returnCode = true;
        }
       
        return returnCode;
View Full Code Here

    }
       
    @Override
    public void closePort() {
        // Stop listening before anything, we're done here.
        SerialPort serialPort = (SerialPort) this.commPort;
        serialPort.removeEventListener();
       
        try {
            in.close();
            out.close();
            in = null;
View Full Code Here

TOP

Related Classes of gnu.io.SerialPort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.