1 pièce(s) jointe(s)
java api rxtx problème d'application inconnue
Bonjour,
j'utilise eclipse.
je bute depuis plusieurs jours sur un problème simple (mais pas pour moi)
quand j'ouvre un port avec portIdentifier.open la console me renvoie "Exception in thread "main" gnu.io.PortInUseException: Unknown Application"
j'ai longuement recherché mais je ne trouve pas la solution. tous les sites que j'ai consulté font la même chose … mais moi ça ne fonctionne pas
Pièce jointe 466256
J'ai vraiment besoin d'aide
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
public class projetBluetooth {
private static Enumeration<CommPortIdentifier> ports;
private static CommPortIdentifier port;
private static String type;
private static String etat;
public static void main(String[] args) throws NoSuchPortException, PortInUseException
{
rxtxAffichage();
System.out.println("getClass.Getname:" + getNomClass());
rxtxOuverturePort("COM6");
}
public static void rxtxAffichage()
{
ports = CommPortIdentifier.getPortIdentifiers();
int i = 1;
while (ports.hasMoreElements())
{
port = (CommPortIdentifier) ports.nextElement();
if (port.getPortType() == CommPortIdentifier.PORT_SERIAL) type = "Serie"; else type = "Parallèle";
if (port.isCurrentlyOwned()) etat = "Possédé par "+port.getCurrentOwner(); else etat = "Libre";
System.out.println("Port : "+ port.getName() + " Type:" + type+ " Etat:"+etat);
}
}
public static void rxtxOuverturePort(String nomPort) throws NoSuchPortException, PortInUseException
{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(nomPort);
CommPort commPort = portIdentifier.open(getNomClass(),2000);
}
public static String getNomClass()
{
projetBluetooth classAdress = new projetBluetooth();
return classAdress.getClass().getName();
}
} |
merci d'avance.