⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readserial.java

📁 用Java在Windows下实现串口全双工通讯的例子
💻 JAVA
字号:
package serial;

import java.io.*;

/**
 * 
 * This class reads message from the specific serial port and save the message
 * to the serial buffer.
 * 
 */
public class ReadSerial extends Thread {
	private SerialBuffer ComBuffer;
	private InputStream ComPort;

	/**
	 * 
	 * Constructor
	 * 
	 * @param SB
	 *            The buffer to save the incoming messages.
	 * @param Port
	 *            The InputStream from the specific serial port.
	 * 
	 */
	public ReadSerial(SerialBuffer SB, InputStream Port) {
		ComBuffer = SB;
		ComPort = Port;
	}

	public void run() {
		int c;
		try {
			while (true) {
				c = ComPort.read();
				ComBuffer.PutChar(c);
			}
		} catch (IOException e) {
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -