110,567
社区成员
发帖
与我相关
我的任务
分享
SerialPort sp1 = new SerialPort();
public void SpIni()
{
sp1.PortName = "COM1";
sp1.BaudRate = 9600;
sp1.ReadTimeout = 400;
sp1.Open();
}
public void SendAndRecv()
{
string StringContext;
byte[] SendBuf = Encoding.ASCII.GetBytes("T1\r");
sp1.Write(SendBuf, 0, SendBuf.Length);
StringContext = "";
StringContext = sp1.ReadLine();
}