Package purejavacomm

Examples of purejavacomm.CommPortIdentifier


     
      openPort();

      // Check ownership of the id of our test port first
      {
        CommPortIdentifier id = CommPortIdentifier
            .getPortIdentifier(m_Port);
        if (id == null) {
          fail("No id for this serial port");
        }

        if (id.getCurrentOwner() == null
            || !id.getCurrentOwner().equals(APPLICATION_NAME)) {
          fail("Wrong or missing owner for this serial port (got \"%s\", expected \"%s\")",
              id.getCurrentOwner(), APPLICATION_NAME);
        }
      }
     
      //first call to enumerate port identifiers
      cpiEnum = CommPortIdentifier.getPortIdentifiers();
     
      //get original owner name
      while (cpiEnum.hasMoreElements()) {
        CommPortIdentifier cpi = cpiEnum.nextElement();
        if (cpi.getName().equals(getPortName())) {
          origOwnerName = cpi.getCurrentOwner();
          break;
        }
      }

      //second call to enumerate port identifiers
      cpiEnum = CommPortIdentifier.getPortIdentifiers();

      //get owner name again
      while (cpiEnum.hasMoreElements()) {
        CommPortIdentifier cpi = cpiEnum.nextElement();
        if (cpi.getName().equals(getPortName())) {
          checkOwnerName = cpi.getCurrentOwner();
          break;
        }
      }
     
      //these should be exactly the same
View Full Code Here


    }
  }

  static protected void openPort() throws Exception {
    try {
      CommPortIdentifier portid = CommPortIdentifier.getPortIdentifier(m_TestPortName);
      m_Port = (SerialPort) portid.open(APPLICATION_NAME, 1000);
      m_Out = m_Port.getOutputStream();
      m_In = m_Port.getInputStream();
      drain(m_In);
    } catch (NoSuchPortException e) {
      fail("could no open port '%s'\n", m_TestPortName);
View Full Code Here

  public static void main(String[] args) throws Exception {
    try {

      //CommPortIdentifier portIdent = CommPortIdentifier.getPortIdentifier("tty.usbserial-FTOXM3NX");
      CommPortIdentifier portIdent = CommPortIdentifier.getPortIdentifier("ttyUSB0");
      port = (SerialPort) portIdent.open("speedtest", 1000);
      messageSize = 200;
      messageCount = 500;

      port.setSerialPortParams(230000, 8, 1, 0);
      port.enableReceiveThreshold(messageSize);
View Full Code Here

  private SerialPort openSerialPort() throws IOException, NoSuchPortException, PortInUseException,
      UnsupportedCommOperationException, TooManyListenersException
  {
    String portName = String.valueOf( this.portSelect.getSelectedItem() );

    CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( portName );

    SerialPort result = ( SerialPort )portId.open( "Serial console tool", 1000 );

    int baudrate = NumberUtils.smartParseInt( String.valueOf( this.portRateSelect.getSelectedItem() ) );

    String db = ( String )this.dataBitsSelect.getSelectedItem();
    int databits;
View Full Code Here

        final Enumeration<CommPortIdentifier> portIdentifiers = CommPortIdentifier.getPortIdentifiers();
        final List<String> portList = new ArrayList<String>();

        while ( portIdentifiers.hasMoreElements() )
        {
          CommPortIdentifier portId = portIdentifiers.nextElement();
          if ( portId.getPortType() == CommPortIdentifier.PORT_SERIAL )
          {
            portList.add( portId.getName() );
          }
        }

        return portList.toArray( new String[portList.size()] );
      }
View Full Code Here

TOP

Related Classes of purejavacomm.CommPortIdentifier

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.