Hallo,
ich habe versucht mit Hilfe von RXTX über den mit einem anderen Grät zu kommunizieren.
Die Kommunikation klappt auch solang auf beiden Seiten die 9600 Baud eingestellt sind. Wenn eine höhere Baudrate eingestellt ist, geht es nicht mehr.
Kann RXTX nicht mehr? Hab auch nichts zur maximalen Übertragungsrate gefunden.
Hier mal mein Code:
Die Zeile:
sPort.setSerialPortParams(800000, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
Danke &MfG
Bob
ich habe versucht mit Hilfe von RXTX über den mit einem anderen Grät zu kommunizieren.
Die Kommunikation klappt auch solang auf beiden Seiten die 9600 Baud eingestellt sind. Wenn eine höhere Baudrate eingestellt ist, geht es nicht mehr.
Kann RXTX nicht mehr? Hab auch nichts zur maximalen Übertragungsrate gefunden.
Hier mal mein Code:
Code:
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
public class Starter implements SerialPortEventListener {
InputStream in;
public static void main(String[] args) {
Starter s = new Starter();
s.portTest();
}
public void portTest(){
SerialPort sPort=null;
CommPortIdentifier portID;
OutputStream out = null;
try{
System.out.println("Port öffnen");
portID = CommPortIdentifier.getPortIdentifier("COM4");
sPort = (SerialPort) portID.open("ME", 2000);
in = sPort.getInputStream();
out = sPort.getOutputStream();
sPort.setSerialPortParams(800000, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
sPort.notifyOnDataAvailable(true);
sPort.addEventListener(this);
System.out.println("Owner: " + portID.getCurrentOwner());
}catch(Exception e){e.printStackTrace();}
try {
out.write(0x55);
out.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void serialEvent(SerialPortEvent arg0) {
try {
int tmp = in.read();
System.out.println("tmp = " + tmp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Die Zeile:
sPort.setSerialPortParams(800000, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
Danke &MfG
Bob