title: I want to detect the device through serial port using RxTx in java
body: <p>I want to detect the device through serial port using RxTx in java and device is programmed that if it recieves a specific word from computer it will reply "ok" and if the computer receives ok.. it will stop sending the word and highlight that the device is attached. PLEASE HELP ME. and one more thing.. i have to check for every port.. please will you code a method that auto-cycle through the ports till the device is detected.
  My code sends the word only one time even being in a infinite loop.
  code:</p>
  
  <pre><code>private void cb1KeyPressed(java.awt.event.KeyEvent evt) {                               
      // TODO add your handling code here:
      try{
      l1.setText("Port: "+cb1.getSelectedItem().toString()+" is Selected");
      selectedPort = cb1.getSelectedItem().toString();// TODO add your handling code here
      rs.connect(selectedPort);
      for(;;)
      {
          CommPortSender.send(new ProtocolImpl().getMessage("KITM"));//send message
          if(pi.rmess().equalsIgnoreCase("OK"))//received message
          {
              l1.setText("The Device is attached to: "+selectedPort);
              CommPortSender.send(new ProtocolImpl().getMessage("OK ACK"));//send message
              break;
          }
          else
          {
              rs.disconnect(selectedPort);
              continue;
          }
      }
      }
      catch(Exception e){}   
  
  }
  </code></pre>