Răsfoiți Sursa

修复Bug:当下位机未实现指令功能时,只返回了一段数据,未返回第二段数据,导致数组索引越界

jianfeng1.wang 2 ani în urmă
părinte
comite
8fb731cc5f

+ 1 - 0
.gitignore

@@ -5,6 +5,7 @@
 FactoryTool_CShare/obj
 FactoryTool_CShare/bin
 FactoryTool_CShare/.vs
+FactoryTool_CShare/.cr
 *.exe
 *.suo
 *.ncb

+ 5 - 0
FactoryTool_CShare/IO/SerialCMD.cs

@@ -2864,6 +2864,11 @@ namespace MOKA_Factory_Tools
                     byte[] receive2Data = new byte[20480];
                     //划一个空间用来存放实际长度
                     int reallyLength=Comport.Read(receive2Data, 0,20480);
+                    if ( reallyLength <= 0 )
+                    {
+                        Log.WriteErrorLog("Received Nothing.");
+                        return false;
+                    }
                     //CRC校验
                     byte crcHighByte = receive2Data[reallyLength - 2];
                     byte crcLowByte = receive2Data[reallyLength - 1];

+ 1 - 1
FactoryTool_CShare/Views/OperationPanel.cs

@@ -5627,7 +5627,6 @@ namespace MOKA_Factory_Tools
             usingTime = 0;
             EnableText(SNText);
             EnableButton(BtnClickstart);
-            SN = "";
             keyInfo = new KeyInfo();
             SetInitialStatus();
             if (WritekeyThread != null)
@@ -5645,6 +5644,7 @@ namespace MOKA_Factory_Tools
                     }
                 }
             }
+            SN = "";  // 需要在线程结束后才能清空;
             UsingTime_Text.Text = "0";
             GC.Collect();
             MessageBox.Show(LResource.RefreshPanel);