本人想用C#写一个实时监测温度的上位机,我用一个串口助手来调试
我发送10.5时候我写的上位机有时候是分开收到1和0.5或者是10和.5
不懂为什么啊 想了很久
以下是串口接收到数据时触发的函数的代码
byte[] readBuffer = new byte[sp.ReadBufferSize];
sp.Read(readBuffer, 0, readBuffer.Length);
sp.DiscardInBuffer();
//赋值
rs = readBuffer;//
string str;
str= Encoding.GetEncoding("ASCII").GetString(rs);
string str2 = "12";
if (str!=str2) { MessageBox.Show(str); }
data.Add(str);
MyValue = 0;