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

📄 serialmain.java

📁 用java实现串口通信 用java实现串口通信
💻 JAVA
字号:
import communication.*;
import java.io.*;
/**
* This is an example of how to use the SerialBean. It opens COM1 and reads
* six messages with different length form the serial port.
*/
class SerialMain
{
	public static void main(String[] args)
	{
		//TO DO: Add your JAVA codes here
		Crc cr=new Crc();
		SerialBean SB = new SerialBean(1);
		SB.Initialize();
		String Msg="";

		//Search
		String[] order=new String[256];
		/*for(int i=0;i<16;++i)
			order[i]="$"+"0"+Integer.toHexString(i).toUpperCase()+"M";//地址0~15转换为地址00~0F
		for(int i=16;i<256;++i)
			order[i]="$"+Integer.toHexString(i).toUpperCase()+"M";//地址16~255转换为地址10~FF
		for(int i=0;i<256;++i)
			order[i]=cr.toCrc(order[i]);
		for (int i=0;i<256;++i)
		{
			SB.WritePort(order[i]);
			Msg=SB.ReadPort(9);
			System.out.println(Msg);
		}*/

		//打开7043D低8位的第一通道
		SB.WritePort("#01000044"+System.getProperty("line.separator"));//加入硬回车
		/*for (int i = 5; i <= 10; i++)
		{
			Msg = SB.ReadPort(i);
			SB.WritePort("Reply: " + Msg);
		}*/
		SB.ClosePort();
	}
}

⌨️ 快捷键说明

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