0

I am trying to develop a application in java (Swing) in which I have to get and store that event coming from device in database. I used RXTX to find all port which is in use but I want only that port in which my device is connected . I used a prolific driver.

private void findPorts() {
  Enumeration<CommPortIdentifier> portEnum =
    CommPortIdentifier.getPortIdentifiers();
  int portCount = 0;

  while ( portEnum.hasMoreElements() ) {
    portIdentifier = portEnum.nextElement();

    // populate the portNames array for display in gui.jcbPort
    //if the port is a serial port
    if(portCount < portNames.length &&
       portIdentifier.getPortType() == portIdentifier.PORT_SERIAL)
    {
      //put it in the array
      portNames[portCount] = portIdentifier.getName();
      portCount++;                
    }
  }        
}
j.w.r
  • 4,136
  • 2
  • 27
  • 29
Kumar Gaurav
  • 193
  • 6
  • 3
    please retag this question, it has nothing to do with swing... you propably have to read the driver's documentation – moeTi Sep 25 '12 at 08:47
  • Post some code snippets, like what you have tried. You need to show you have done some research and put some effort before asking a question. – Raul Rene Sep 25 '12 at 10:00
  • Here is my code it gives me all port which is used but i want a particular port in which my device is connected and i used a pl2303 prolific drivet for my usb device ...@RahulGogo` ------------------ – Kumar Gaurav Sep 26 '12 at 05:18
  • @KumarGaurav there was a similar question/solution here http://stackoverflow.com/questions/6362775/getting-device-driver-information-related-to-a-com-port – likejudo Mar 10 '13 at 03:28

0 Answers0