|
|
@@ -78,25 +78,14 @@ namespace UAS_MES_NEW.SystemSetting
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Thread.Sleep(100);
|
|
|
int len = serialPort1.BytesToRead;
|
|
|
Byte[] readBuffer = new Byte[len];
|
|
|
serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
|
|
|
string weigh = Encoding.Default.GetString(readBuffer);
|
|
|
- if (weigh != ""&& weigh.Length>10)
|
|
|
+ Remark.AppendText(weigh + "\n");
|
|
|
+ if (weigh != "")
|
|
|
{
|
|
|
- int firstIndex = weigh.IndexOf("="); // 查找第一个"="的索引
|
|
|
- int secondIndex = weigh.IndexOf("=", firstIndex + 1); // 查找第二个"="的索引
|
|
|
- string result = weigh.Substring(firstIndex + 1, secondIndex - firstIndex - 1);// 提取第一个"="和第二个"="之间的字符
|
|
|
- result = new string(result.ToCharArray().Reverse().ToArray());
|
|
|
- int index = 0;
|
|
|
- while (index < result.Length && result[index] == '0')
|
|
|
- {
|
|
|
- index++;
|
|
|
- }
|
|
|
- result = result.Substring(index);
|
|
|
- Remark.AppendText(result+"\n");
|
|
|
- Weight.Text = result;
|
|
|
+ Weight.Text = weigh;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception)
|