Package gnu.io

Examples of gnu.io.CommPort


        private void connectInternal()
                throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException,
                TooManyListenersException {

            final CommPort commPort;
            try {

                final CommPortIdentifier cpi =
                        CommPortIdentifier.getPortIdentifier(channelSink.remoteAddress.getDeviceAddress());
                commPort = cpi.open(this.getClass().getName(), 1000);
View Full Code Here


            System.out.println("Port \"" + port.getName() + "\" in use.");
            return null;
        } // open the port
        SerialPort serialPort = null;
        try {
            CommPort cPort = port.open(APP_ID, PORT_OPENTIME);//2 seconds wait
            if (cPort instanceof SerialPort) {
                serialPort = (SerialPort) cPort;
            } else {
                System.out.println("Port \"" + port.getName() + "\" is not a serial port.");
                cPort.close();
                return null;
            }
        } catch (PortInUseException e) {
            System.out.println("Port \"" + port.getName() + "\" in use.");
            return null;
View Full Code Here

        while (thePorts.hasMoreElements()) {
            CommPortIdentifier com = (CommPortIdentifier) thePorts.nextElement();
            switch (com.getPortType()) {
            case CommPortIdentifier.PORT_SERIAL:
                try {
                    CommPort thePort = com.open("CommUtil", 50);
                    thePort.close();
                    h.add(com);
                 Main.log.addLine("Port, "  + com.getName() + ", is available.");
                   
                    jComPortBox.addItem(com.getName());
                } catch (PortInUseException e) {
View Full Code Here

    @Override
    protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
        RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress;
        final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value());
        final CommPort commPort = cpi.open(getClass().getName(), 1000);

        deviceAddress = remote;

        serialPort = (SerialPort) commPort;
    }
View Full Code Here

    CommPortIdentifier portIdentifier = CommPortIdentifier
        .getPortIdentifier(portName);
    if (portIdentifier.isCurrentlyOwned()) {
      throw new IOException("Port is currently in use");
    } else {
      CommPort commPort = portIdentifier.open(this.getClass().getName(),
          TIME_OUT);

      if (commPort instanceof SerialPort) {
        SerialPort serialPort = (SerialPort) commPort;
        serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
View Full Code Here

        Enumeration ports = CommPortIdentifier.getPortIdentifiers();
        while (ports.hasMoreElements()) {
            CommPortIdentifier com = (CommPortIdentifier) ports.nextElement();
            if (com.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                try {
                    CommPort port = com.open("CommUtil", 50);
                    port.close();
                    p.add(com.getName());
                } catch (PortInUseException e) {
                    Log.info("Port " + com.getName() + " busy.");
                } catch (Exception e) {
                    Log.info("Failed to open port " + com.getName());
View Full Code Here

    if ( ! isCommonPortname ) {
            System.setProperty("gnu.io.rxtx.SerialPorts", portname);
        }
    System.setProperty("gnu.io.rxtx.NoVersionOutput", "true");
    CommPortIdentifier commPortIdentifier = CommPortIdentifier.getPortIdentifier(portname);
    CommPort commPort = commPortIdentifier.open("tc65sh", 2000);
    serialPort = (SerialPort) commPort;
    serialPort.setSerialPortParams(baudrate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    serialPort.enableReceiveTimeout(2000);
    if ( flowControl == FLOWCONTROL_NONE ) {
      serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
View Full Code Here

        {
            System.out.println("Error: Port is currently in use");
        }
        else
        {
            CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
           
            if ( commPort instanceof SerialPort )
            {
                serialPort = (SerialPort) commPort;
                serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
View Full Code Here

  // an exception is generated
  public void connect() {
    String selectedPort = (String) window.cBoxPorts.getSelectedItem();
    selectedPortIdentifier = portMap.get(selectedPort);

    CommPort commPort = null;

    try {
      // the method below returns an object of type CommPort
      commPort = selectedPortIdentifier.open("SYSC 2003 Robot Debug",
          TIMEOUT);
View Full Code Here

    CommPortIdentifier portIdentifier = CommPortIdentifier
        .getPortIdentifier(com);
    // if (portIdentifier.isCurrentlyOwned()) {
    // System.out.println("Error: Port is currently in use");
    // } else {
    CommPort commPort = portIdentifier
        .open(this.getClass().getName(), 2000);
    if (commPort instanceof SerialPort) {
      s = (SerialPort) commPort;
      s.setSerialPortParams(115200, SerialPort.DATABITS_8,
          SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
View Full Code Here

TOP

Related Classes of gnu.io.CommPort

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.