Brug af Serialport
Hej,jeg forsøger at benytte en serialport på et embedded system, men det giver nogle problemer. Nu for jeg så forsøgt at få det til at virke på computer, men samme fejl.
Her er det første af min kode:
public class RS232 {
private SerialPort serialPort;//the port we have open
private OutputStream out;//outputstream for the port
//private InputStream in;//inputstream for the port
public RS232(String portName) {
//throw a runtime exception if it was not possible to open the port
CommPortIdentifier portId;
try {
portId = CommPortIdentifier.getPortIdentifier(portName); <---- Fejl her
}
catch (NoSuchPortException e) {
throw new RuntimeException("No such port: serial4");
}
if (portId.getPortType() != CommPortIdentifier.PORT_SERIAL)
throw new RuntimeException("serial4 is not a serial port");
Jeg har lige lavet en anmærkning om hvor fejl kommer.
Fejlen:
NullPointerException:
name can't be null (in java.io.FilePermission)
Jeg også prøvet at erstatte portName med "COM2", men det giver samme fejl :-(
Nogen forslag?
