1 pièce(s) jointe(s)
Message Erreur au niveau portIseexception
Bonjour
J'ai cette erreur Pièce jointe 222808
Voici mon code
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| package fr.issmi.controller;
import fr.issmi.utils.Util;
import gnu.io.CommPortIdentifier;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;
import java.io.OutputStream;
import java.util.List;
public class SerialController {
private List<CommPortIdentifier> portIdentifiers;
private SerialPort serialPort;
private OutputStream outputStream;
public SerialController() {
this.portIdentifiers = Util.getPortIdentifiers();
}
@SuppressWarnings({"unchecked"})
public SerialPort selectSerialPort(int anIndex) {
try {
final CommPortIdentifier cpi = this.portIdentifiers.get(anIndex);
final SerialPort sp = (SerialPort)cpi.open("Ghiles", 2000);
//serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
this.outputStream = sp.getOutputStream();
return sp;
}catch(PortInUseException e) {
Util.showError(e.getMessage());
}catch(Exception e) {
Util.showError(e.getMessage());
}
return null;
}
public List<CommPortIdentifier> getPortIdentifiers() {
return portIdentifiers;
}
public void setPortIdentifiers(List<CommPortIdentifier> portIdentifiers) {
this.portIdentifiers = portIdentifiers;
}
public SerialPort getSerialPort() {
return serialPort;
}
public void setSerialPort(SerialPort serialPort) {
this.serialPort = serialPort;
}
public OutputStream getOutputStream() {
return outputStream;
}
public void setOutputStream(OutputStream outputStream) {
this.outputStream = outputStream;
}
} |
Merci