Examples of CommPortIdentifier


Examples of javax.comm.CommPortIdentifier

  public SerialConnection(String aPort) throws SerialServerException {
    if (SerialServerProperties.getInstance().getDebugLevel() > 2) {
      debug = true;
    }
    Enumeration portList = CommPortIdentifier.getPortIdentifiers();
    CommPortIdentifier portId = null;
    while (portList.hasMoreElements()) {
      portId = (CommPortIdentifier) portList.nextElement();
      if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL &&
        portId.getName().equals(aPort)) {
        break;
      }
    }
   
    try {
      serialPort = (SerialPort) portId.open("SerialConnection", 2000);
      outputStream = serialPort.getOutputStream();
      inputStream = serialPort.getInputStream();
      serialPort.setSerialPortParams(9600,
          SerialPort.DATABITS_8,
          SerialPort.STOPBITS_2,
View Full Code Here

Examples of javax.comm.CommPortIdentifier

     * @throws UnsupportedCommOperationException
     * @throws PortInUseException
     */
    public UARTTransport(String commPortName) throws HCIException {
        try {
            CommPortIdentifier commPort = CommPortIdentifier.getPortIdentifier(commPortName);
            if (commPort.getPortType() != CommPortIdentifier.PORT_SERIAL)
                throw new HCIException(commPortName + " is not a serial port. ");
            SerialPort serial = (SerialPort)commPort.open("Bluetooth", 10000);
            serial.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            inStream = serial.getInputStream();
            outStream = serial.getOutputStream();
            readBuffer = new byte[32];
            serial.addEventListener(this);
View Full Code Here

Examples of javax.comm.CommPortIdentifier

        // Enumerate the available ports.
        Enumeration ports = CommPortIdentifier.getPortIdentifiers();
        String defaultChoice = null;

        while (ports.hasMoreElements()) {
            CommPortIdentifier identifier = (CommPortIdentifier) ports
                    .nextElement();

            if (identifier.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                String value = identifier.getName();
                serialPortName.addChoice(value);

                if (defaultChoice == null) {
                    defaultChoice = value;
                }
View Full Code Here

Examples of javax.comm.CommPortIdentifier

        super.preinitialize();
        _directorFiredAtAlready = false;

        try {
            String serialPortNameValue = serialPortName.stringValue();
            CommPortIdentifier portID = CommPortIdentifier
                    .getPortIdentifier(serialPortNameValue);
            synchronized (PortListener.class) {
                if (_serialPort == null
                        || !toplevel().getName().equals(
                                portID.getCurrentOwner())) {
                    // NOTE: Do not do this in a static initializer so that
                    // we don't initialize the port if there is no actor using it.
                    // This is synchronized on the SerialComm class to prevent multiple actors
                    // from trying to do this simultaneously.
                    _serialPort = (SerialPort) portID.open(
                            toplevel().getName(), 2000);
                    if (_serialPortListener == null) {
                        // This should only be done once.
                        _serialPortListener = new PortListener();
                    }
View Full Code Here

Examples of javax.comm.CommPortIdentifier

  }

  public static void main(String[] args)
  {
    Enumeration     ports;
    CommPortIdentifier  portId;
    boolean      allPorts = true,
          lineMonitor = false;
    int      idx = 0;

    win = new BlackBox();
    win.setLayout(new FlowLayout());
    win.setBackground(Color.gray);

    portDisp = new SerialPortDisplay[40];

    while (args.length > idx)
    {
      if (args[idx].equals("-h"))
      {
        printUsage();
      }

      else if (args[idx].equals("-f"))
      {
        friendly = true;
 
        System.out.println("Friendly mode");
      }

      else if (args[idx].equals("-n"))
      {
        threaded = false;
 
        System.out.println("No threads");
      }

      else if (args[idx].equals("-l"))
      {
        lineMonitor = true;
 
        System.out.println("Line Monitor mode");
      }

      else if (args[idx].equals("-m"))
      {
        modemMode = true;
 
        System.out.println("Modem mode");
      }

      else if (args[idx].equals("-s"))
      {
        silentReceive = true;
 
        System.out.println("Silent Reciever");
      }

      else if (args[idx].equals("-d"))
      {
        idx++;
        rcvDelay = new Integer(args[idx]).intValue();
 
        System.out.println("Receive delay = "
              + rcvDelay + " msecs");
      }

      else if (args[idx].equals("-p"))
      {
        idx++;

        while (args.length > idx)
        {
          /*
           *  Get the specific port
           */
   
          try
          {
            portId =
               CommPortIdentifier.getPortIdentifier(args[idx]);

            System.out.println("Opening port "
                  + portId.getName());
 
            win.addPort(portId);
          }
 
          catch (NoSuchPortException e)
View Full Code Here

Examples of javax.comm.CommPortIdentifier

     *
     * @see
     */
    public static void main(String[] args) {
  Enumeration     ports;
  CommPortIdentifier portId;
  boolean       allPorts = true, lineMonitor = false;
  int       idx = 0;

  win = new ParallelBlackBox();

  win.setLayout(new FlowLayout());
  win.setBackground(Color.gray);

  portDisp = new ParallelPortDisplay[4];

  while (args.length > idx) {
      if (args[idx].equals("-h")) {
    printUsage();
      } else if (args[idx].equals("-f")) {
    friendly = true;

    System.out.println("Friendly mode");
      } else if (args[idx].equals("-n")) {
    threaded = false;

    System.out.println("No threads");
      } else if (args[idx].equals("-l")) {
    lineMonitor = true;

    System.out.println("Line Monitor mode");
      } else if (args[idx].equals("-d")) {
    idx++;
    rcvDelay = new Integer(args[idx]).intValue();

    System.out.println("Receive delay = " + rcvDelay + " msecs");
      } else if (args[idx].equals("-p")) {
    idx++;

    while (args.length > idx) {

        /*
         * Get the specific port
         */
        try {
      portId =
          CommPortIdentifier.getPortIdentifier(args[idx]);

      System.out.println("Opening port "
             + portId.getName());
      win.addPort(portId);
        } catch (NoSuchPortException e) {
      System.out.println("Port " + args[idx]
             + " not found!");
        }
View Full Code Here

Examples of javax.comm.CommPortIdentifier

  }

  public static void main(String[] args)
  {
    Enumeration     ports;
    CommPortIdentifier  portId;
    boolean      allPorts = true,
          lineMonitor = false;
    int      idx = 0;

    win = new ParallelBlackBox();
    win.setLayout(new FlowLayout());
    win.setBackground(Color.gray);

    portDisp = new ParallelPortDisplay[4];

    while (args.length > idx)
    {
      if (args[idx].equals("-h"))
      {
        printUsage();
      }

      else if (args[idx].equals("-f"))
      {
        friendly = true;
 
        System.out.println("Friendly mode");
      }

      else if (args[idx].equals("-n"))
      {
        threaded = false;
 
        System.out.println("No threads");
      }

      else if (args[idx].equals("-l"))
      {
        lineMonitor = true;
 
        System.out.println("Line Monitor mode");
      }

      else if (args[idx].equals("-d"))
      {
        idx++;
        rcvDelay = new Integer(args[idx]).intValue();
 
        System.out.println("Receive delay = "
              + rcvDelay + " msecs");
      }

      else if (args[idx].equals("-p"))
      {
        idx++;

        while (args.length > idx)
        {
          /*
           *  Get the specific port
           */
   
          try
          {
            portId =
               CommPortIdentifier.getPortIdentifier(args[idx]);

            System.out.println("Opening port "
                  + portId.getName());
 
            win.addPort(portId);
          }
 
          catch (NoSuchPortException e)
View Full Code Here

Examples of javax.comm.CommPortIdentifier

  }

  public static void main(String[] args)
  {
    Enumeration     ports;
    CommPortIdentifier  portId;
    boolean      allPorts = true,
          lineMonitor = false;
    int      idx = 0;

    win = new BlackBox();
    win.setLayout(new FlowLayout());
    win.setBackground(Color.gray);

    portDisp = new SerialPortDisplay[4];

    while (args.length > idx)
    {
      if (args[idx].equals("-h"))
      {
        printUsage();
      }

      else if (args[idx].equals("-f"))
      {
        friendly = true;
 
        System.out.println("Friendly mode");
      }

      else if (args[idx].equals("-n"))
      {
        threaded = false;
 
        System.out.println("No threads");
      }

      else if (args[idx].equals("-l"))
      {
        lineMonitor = true;
 
        System.out.println("Line Monitor mode");
      }

      else if (args[idx].equals("-m"))
      {
        modemMode = true;
 
        System.out.println("Modem mode");
      }

      else if (args[idx].equals("-s"))
      {
        silentReceive = true;
 
        System.out.println("Silent Reciever");
      }

      else if (args[idx].equals("-d"))
      {
        idx++;
        rcvDelay = new Integer(args[idx]).intValue();
 
        System.out.println("Receive delay = "
              + rcvDelay + " msecs");
      }

      else if (args[idx].equals("-p"))
      {
        idx++;

        while (args.length > idx)
        {
          /*
           *  Get the specific port
           */
   
          try
          {
            portId =
               CommPortIdentifier.getPortIdentifier(args[idx]);

            System.out.println("Opening port "
                  + portId.getName());
 
            win.addPort(portId);
          }
 
          catch (NoSuchPortException e)
View Full Code Here

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

Examples of purejavacomm.CommPortIdentifier

    }
  }

  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
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.