Hallo zusammen,
ich habe ein Problem mit der seriellen Schnittstellenprogrammierung mit java auf meinem Raspberry.
Ich bekommen den Fehler
TwoWaySerialComm.java:8: error: cannot find symbol CommPortIdentifier portIdentifier = CommPortIdentifier
wenn ich folgendes Programm kompiliere, obwohl RXTXcomm.jar im classpath ist.
Kann mir da jemand helfen?
Java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TwoWaySerialComm {
void connect( String portName ) throws Exception {
CommPortIdentifier portIdentifier = CommPortIdentifier
.getPortIdentifier( portName );
if( portIdentifier.isCurrentlyOwned() ) {
System.out.println( "Error: Port is currently in use" );
} else {
int timeout = 2000;
CommPort commPort = portIdentifier.open( this.getClass().getName(), timeout );
if( commPort instanceof SerialPort ) {
SerialPort serialPort = ( SerialPort )commPort;
serialPort.setSerialPortParams( 57600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE );
InputStream in = serialPort.getInputStream();
OutputStream out = serialPort.getOutputStream();
( new Thread( new SerialReader( in ) ) ).start();
( new Thread( new SerialWriter( out ) ) ).start();
} else {
System.out.println( "Error: Only serial ports are handled by this example." );
}
}
}
Alles anzeigen