{
Application.DoEvents();
}
return;
}
private void Config_Resize(object sender, EventArgs e)
{
this.FormBorderStyle =System.Windows.Forms.FormBorderStyle.None;
}
}
Comm.cs文件代码:
using System.Text;
using System;
using System.Threading;
using System.IO;
using System.IO.Ports;
using System.Windows.Forms;
public class Comm
{
private SerialPort port;
private byte[] readcache;
private int idx;
public string SendOK;
public string s2;
public string s3;
public delegate void DataEventHandler(string RevCmd, string RevData);
public event DataEventHandler HaveDataReady;
public Comm(string spName, int spBaudRate, Parity spParity, int spDataBits, StopBits spStopBits, Handshake spHandShake)
{
port = new SerialPort(spName, spBaudRate, spParity, spDataBits, spStopBits);
port.Handshake = spHandShake;
port.ReadTimeout = 500;
port.WriteTimeout = 500;
port.ReadBufferSize = 1024;
port.ReceivedBytesThreshold = 1;
port.DataReceived += new SerialDataReceivedEventHandler(portDataReceived);
readcache = new byte[256];
idx = 0;
}
public bool IsOpen()
{
return port.IsOpen;
}
public void Open()
{
port.Open();
}
public void Close()
{
port.Close();
}
public void portDataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
byte inputData = 0;
while ((port.BytesToRead > 0))
{