Package gnu.io

Examples of gnu.io.CommPortIdentifier


    @Override
    protected synchronized ConnectFuture connect0(
            SocketAddress remoteAddress, SocketAddress localAddress,
            IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {

        CommPortIdentifier portId;
        Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();

        SerialAddress portAddress = (SerialAddress) remoteAddress;

        // looping around found ports
        while (portList.hasMoreElements()) {
            portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (log.isDebugEnabled()) {
                    log.debug("Serial port discovered : " + portId.getName());
                }
                if (portId.getName().equals(portAddress.getName())) {
                    try {
                        if (log.isDebugEnabled()) {
                            log
                                    .debug("Serial port found : "
                                            + portId.getName());
                        }

                        SerialPort serialPort = initializePort("Apache MINA",
                                portId, portAddress);
View Full Code Here


    @Override
    protected synchronized ConnectFuture connect0(SocketAddress remoteAddress, SocketAddress localAddress,
            IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {

        CommPortIdentifier portId;
        Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();

        SerialAddress portAddress = (SerialAddress) remoteAddress;

        // looping around found ports
        while (portList.hasMoreElements()) {
            portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (log.isDebugEnabled()) {
                    log.debug("Serial port discovered : " + portId.getName());
                }
                if (portId.getName().equals(portAddress.getName())) {
                    try {
                        if (log.isDebugEnabled()) {
                            log.debug("Serial port found : " + portId.getName());
                        }

                        SerialPort serialPort = initializePort("Apache MINA", portId, portAddress);

                        ConnectFuture future = new DefaultConnectFuture();
View Full Code Here

  static SerialComm sc;
  static RobotCamColorTrack prueba;
  static OutputStream out;
  public static void main(String[] args) throws Exception {

    CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( "COM3d" );
    SerialPort sp = (SerialPort)portId.open("SerialCommunicationChannel", 2000);

    sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    out  = sp.getOutputStream();
   
    DataInputStream i=new DataInputStream(System.in);
View Full Code Here

//    sc = new SerialCommunicationChannel();
//    sc.open("banana, COM5");

//    sc.send("advance");

    CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( "COM6" );
    SerialPort sp = (SerialPort)portId.open("SerialCommunicationChannel", 2000);

    sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    out  = sp.getOutputStream();
//    sc = new SerialComm("6",3);*/

 
View Full Code Here

    if(args==null || (args!=null && args.length<1)) {
      System.out.println("Es necesario especificar por par�metro el puerto COM a utilizar - Ej: 'java -jar SimpleBot.jar COM4'");
      return;
    }
   
    CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( args[0] );
    SerialPort sp = (SerialPort)portId.open("SerialCommunicationChannel", 2000);

    sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    out  = sp.getOutputStream();

    prueba = new RobotCamColorTrack("3");
View Full Code Here

  {
    Enumeration pList = CommPortIdentifier.getPortIdentifiers();
      // Process the list.
      while (pList.hasMoreElements())
      {
        CommPortIdentifier cpi = (CommPortIdentifier) pList.nextElement();
        if (cpi.getPortType() == CommPortIdentifier.PORT_SERIAL)
          if (cpi.isCurrentlyOwned()) {
            commCombo.add(cpi.getName()+ "(usado)");           
            frontCamPortCombo.add(cpi.getName()+ "(usado)");
          }
          else {
            commCombo.add(cpi.getName());
            frontCamPortCombo.add(cpi.getName());
          }
      } 
  }
View Full Code Here

  {
    Enumeration pList = CommPortIdentifier.getPortIdentifiers();
      // Process the list.
      while (pList.hasMoreElements())
      {
        CommPortIdentifier cpi = (CommPortIdentifier) pList.nextElement();
        if (cpi.getPortType() == CommPortIdentifier.PORT_SERIAL)
          if (cpi.isCurrentlyOwned()) {
            commCombo.add(cpi.getName()+ "(usado)");           
            frontCamPortCombo.add(cpi.getName()+ "(usado)");
          }
          else {
            commCombo.add(cpi.getName());
            frontCamPortCombo.add(cpi.getName());
          }
      } 
  }
View Full Code Here

     }
        
    public  static void connect ( String portName, String baudRate) throws Exception
    {
        isConnected=true;
        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
       Main.log.addLine(".. connecting: "+portName);
        if ( portIdentifier.isCurrentlyOwned() )
        {
         //   System.out.println("Error: Port is currently in use");
          Main.log.addLine("Error: Port is currently in use");
        }
        else
        {
           
            commPort = portIdentifier.open("jStation",2000);
           
            if ( commPort instanceof SerialPort )
            {
                SerialPort serialPort = (SerialPort) commPort;
               
View Full Code Here

    public void getAvailableSerialPorts() {
        HashSet<CommPortIdentifier> h = new HashSet<CommPortIdentifier>();
        Enumeration thePorts = CommPortIdentifier.getPortIdentifiers();
        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) {
                  Main.log.addLine("Port, "  + com.getName() + ", is in use.");
                } catch (Exception e) {
                  Main.log.addLine("Port, "  + com.getName() + ", failed to open.");
                   
                    e.printStackTrace();
                }
            }
        }
View Full Code Here

    @Override
    protected ConnectFuture connect0(
            SocketAddress remoteAddress, SocketAddress localAddress,
            IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {

        CommPortIdentifier portId;
        Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();

        SerialAddress portAddress = (SerialAddress) remoteAddress;

        // looping around found ports
        while (portList.hasMoreElements()) {
            portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (log.isDebugEnabled()) {
                    log.debug("Serial port discovered : " + portId.getName());
                }
                if (portId.getName().equals(portAddress.getName())) {
                    try {
                        if (log.isDebugEnabled()) {
                            log
                                    .debug("Serial port found : "
                                            + portId.getName());
                        }

                        SerialPort serialPort = initializePort("Apache MINA",
                                portId, portAddress);
View Full Code Here

TOP

Related Classes of gnu.io.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.