private void connect (String portName, int threshold) throws Exception
{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if ( portIdentifier.isCurrentlyOwned() )
{
appender.append("Error: Port is currently in use");
}
else
{
//from RXTX examples
CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
if (commPort instanceof SerialPort)
{
//set up serial port
serialPort = (SerialPort) commPort;
serialPort.enableReceiveTimeout(threshold);
serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_2,SerialPort.PARITY_NONE);
//start async reader
sr = new SerialReader(serialPort, server);
serailThread = new Thread(sr);
serailThread.start();
}
else
{
appender.append("Error: Only serial ports are handled by this example.");
}
}
}
FpgaSerial.java 文件源码
java
阅读 15
收藏 0
点赞 0
评论 0
项目:fpga-shovel-and-pickaxe
作者:
评论列表
文章目录