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

📄 readserial.java

📁 用java实现串口通信 用java实现串口通信
💻 JAVA
字号:
package communication;
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;//ComBuffer是存储串口传来数据的缓冲区!!!!
	private InputStream inPort;
/**
* 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;
	inPort = Port;
	}
	public void run()
	{
	int c;
	try
	{
		while (true)
		{
			c = inPort.read();
			ComBuffer.PutChar(c);
		}
	} catch (IOException e) {}
	}
}

⌨️ 快捷键说明

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