Hi there,
Try this:

ports = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
            portId = (CommPortIdentifier) portList.nextElement();

            if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (portId.getName().equals("COM1")) {

                              /*Rest of Code*/
                 }
             }
}

Regards,
Andrew
>>> "zhiqiang zhang" <[EMAIL PROTECTED]> 06/30/06 5:13 AM >>>
hi,everyone 


   Recently ,i found a strange problem.

   I wrote a java file to print all the port on the command line. The source
code i attached below:

*import java.util.*;
import java.io.*;
import javax.comm.*;*

*public class listenraw {
 public static void main(String argv[]) {
  new listenraw();
 }*

* public listenraw() {
  CommPortIdentifier portId;*

*  Enumeration ports = CommPortIdentifier.getPortIdentifiers();*

*  if (ports == null) {
   System.out.println("No comm ports found!");
   return;
  }*

*  // print out all ports
  System.out.println("printing all ports...");
  while (ports.hasMoreElements()) {
   System.out.println("  "
     + ((CommPortIdentifier) ports.nextElement()).getName());*

*  }
 }
}
*

The result was :*printing all ports...*   It meant*
ports.hasMoreElements()*return false.

But from the device manager i found there are COM1 and COM2 occurred.

Can anyone tell me how can i solve the problem.

*
*

--------------------------------------------------------------------
Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Peninsula University of 
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.cput.ac.za/email.php or call +27 (0)21 460 3911

_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to