Comm não acha portas

1 resposta
L

Estou com problemas com o pacote comm, tipo ele não acha nenhuma porta, alguém sabe me dizer oq eh?

public static void main(String[] args) { int i = 0; Enumeration listaDePortas; listaDePortas = CommPortIdentifier.getPortIdentifiers(); String portas[] = new String[10]; while (listaDePortas.hasMoreElements()) { CommPortIdentifier ips = (CommPortIdentifier)listaDePortas.nextElement(); portas[i] = ips.getName(); i++; } for(int l=0; l < portas.length; l++){ System.out.print(portas[l] + ": " + l + (char)10); } }

retorno:

null: 0
null: 1
null: 2
null: 3
null: 4
null: 5
null: 6
null: 7
null: 8
null: 9

e ta tudo instaladinho certinho minhas portas e drivers, COM1, COM2 e LPT1…

alguém tem idéia do que se passa??

Abracetas… :wink:

1 Resposta

J

Você verificou se está setando certo?

Faz assim:
public static void main(String[] args) {    
      int i = 0; 
      Enumeration listaDePortas; 
      listaDePortas = CommPortIdentifier.getPortIdentifiers(); 
      String portas[] = new String[10]; 
      while (listaDePortas.hasMoreElements()) { 
         CommPortIdentifier ips = (CommPortIdentifier)listaDePortas.nextElement(); 
         portas[i] = ips.getName(); 

// teste
         System.out.println(i + ". " + portas[i] + " - " + ips.getName());
// teste

         i++; 
      } 
      for(int l=0; l < portas.length; l++){ 
         System.out.print(portas[l] + ": " + l + (char)10); 
      } 
   }

Ou se você estiver usando uma IDE e souber como fazer para consultar... do it.

Criado 31 de julho de 2005
Ultima resposta 1 de ago. de 2005
Respostas 1
Participantes 2