private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
// 获取字节长度
int bytes = serialPort1.BytesToRead;
// 创建字节数组
byte[] buffer = new byte[bytes];
// 读取缓冲区的数据到数组
serialPort1.Read(buffer, 0, bytes);
this.textBox1.Invoke
(
new MethodInvoker
(
delegate
{
this.textBox1.AppendText(System.Text.Encoding.Unicode.GetString(buffer));
}
)
);
}