Examples of SerialPort


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

Examples of gnu.io.SerialPort

    } 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

Examples of gnu.io.SerialPort

                    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

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());
        serialPort.setOutputBufferSize(config.getOutputBufferSize());

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

        return serialPort;
    }
View Full Code Here

Examples of gnu.io.SerialPort

            {
              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

Examples of gnu.io.SerialPort

  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

Examples of gnu.io.SerialPort

                            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

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());
        serialPort.setOutputBufferSize(config.getOutputBufferSize());

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

        return serialPort;
    }
View Full Code Here

Examples of javax.comm.SerialPort

    }
  }

  public void itemStateChanged(ItemEvent  ev)
  {
    SerialPort  port;
    String     sel = (String) ev.getItem();
    int    value = 0;

    if (sel.equals("None"))
    {
      value = SerialPort.PARITY_NONE;
    }

    else if (sel.equals("Odd"))
    {
      value = SerialPort.PARITY_ODD;
    }

    else if (sel.equals("Even"))
    {
      value = SerialPort.PARITY_EVEN;
    }

    else
    {
      this.showValue();
    }

    port = this.owner.port;

    if ((value > 0) && (port != null))
    {
      /*
       *  Set the parity.
       *
       *  Note: we must set all of the parameters, not just
       *  the parity, hence the use of get*
       */

      try
      {
        port.setSerialPortParams(port.getBaudRate(),
               port.getDataBits(),
               port.getStopBits(),
               value);
      }
   
      catch (UnsupportedCommOperationException e)
      {
        System.out.println("Cannot set parity to "
               + sel + " for port "
               + port.getName());
      }
    }

    this.owner.showValues();
  }
View Full Code Here

Examples of javax.comm.SerialPort

    System.exit(0);
  }

  private void cleanup()
  {
    SerialPort  p;

    while (portNum > 0)
    {
      portNum--;
      panelNum--;

      /*
       *  Close the port
       */

      p = portDisp[portNum].getPort();

      if (p != null)
      {
        System.out.println("Closing port "
               + portNum
               + " ("
               + p.getName()
               + ")");

        portDisp[portNum].closeBBPort();
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.