Package javax.comm

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


     * @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

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

        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

  }

  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

     *
     * @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

  }

  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

  }

  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

      getContentPane().add("South", p2);
      resize(300, 100);
   }

   private boolean listPorts() {
      CommPortIdentifier defaultPort;
      try {
         defaultPort = CommPortIdentifier.getPortIdentifier(defaultPortName);
      } catch (NoSuchPortException e) {
         defaultPort = null;
      }
      Enumeration ports = defaultPort.getPortIdentifiers();
      String name;
      int added = 0;
      for (Enumeration e = ports; e.hasMoreElements();) {

         CommPortIdentifier portIdentifier = (CommPortIdentifier) e
               .nextElement();
         name = portIdentifier.getName();

         int type = portIdentifier.getPortType();

         // Can only use serial ports
         if (type != CommPortIdentifier.PORT_SERIAL) {
            System.out
                  .println("PortDialog.listenForPort() non serial com port, excluding it: "
View Full Code Here

    */

   private SerialPort getOpenPort(String portName) {
      Object found = c_ports.get(portName);
      SerialPort port = null;
      CommPortIdentifier portId = null;
      try {
         portId = CommPortIdentifier.getPortIdentifier(portName);
      } catch (Exception e) {
      }
      if (found == null) {
         try {
            port = (SerialPort) portId.open("SerialPortConnection", 2000);
         } catch (PortInUseException e) {
            return null;
         }
         c_ports.put(portName, port);
      } else {
View Full Code Here

TOP

Related Classes of javax.comm.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.