串口读取数据修改

apiclient现场测试
This commit is contained in:
zhougf committed 2025-03-07 22:07:51 +08:00
1 parent 6c7278ed45
commit 2bd24f5316
3 files changed
+176 -107

No files matched your search

+8 -1
View File
@@ -66,7 +66,14 @@ namespace WindowsFormsApp1
Init.ScanPort?.Open();
}
// 读取串口接收到的数据
ReturnValue = Init.ScanPort.ReadExisting();
var dataBuilder = new StringBuilder();
while(Init.ScanPort.BytesToRead > 0)
{
System.Threading.Thread.Sleep(100);
dataBuilder.Append(Init.ScanPort.ReadExisting());
}
ReturnValue = dataBuilder.ToString();
if (this.InvokeRequired)
{
this.Invoke(new Action(() =>