/**
* Versucht den seriellen Port zu �ffnen. Klappt nur, wenn er noch nicht von einer anderen Anwendung benutzt wird. Der jeweilige
* Port wird mit �bergeben. UNter Windows ist die Schreibweise "COM8" zum Beispeil unter Linux "dev/tts0"
* @param portName
* @return
* @throws PortInUseException
* @throws IOException
* @throws UnsupportedCommOperationException
*/
public boolean oeffneSerialPort(String portName) throws PortInUseException, IOException, UnsupportedCommOperationException
{
Boolean foundPort = false;
if (serialPortGeoeffnet != false) {
System.out.println("Serialport bereits ge�ffnet");
schliesseSerialPort();
return false;
}
System.out.println("�ffne Serialport");
enumComm = CommPortIdentifier.getPortIdentifiers();
while(enumComm.hasMoreElements()) {
serialPortId = (CommPortIdentifier) enumComm.nextElement();
System.out.println("SerialportIDs:" + serialPortId.getName());
if (portName.contentEquals(serialPortId.getName())) {
foundPort = true;
break;
}
}
if (foundPort != true) {
System.out.println("Serialport nicht gefunden: " + portName);
return false;
}
serialPort = (SerialPort) serialPortId.open("�ffnen und Senden", 500);
outputStream = serialPort.getOutputStream();
inputStream = serialPort.getInputStream();
serialPort.notifyOnDataAvailable(true);
serialPort.setSerialPortParams(baudrate, dataBits, stopBits, parity);
serialPortGeoeffnet = true;
return true;
}
VCDSerialPort.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:EasyVote
作者:
评论列表
文章目录