Explorar el Código

指令长度截取

章政 hace 7 años
padre
commit
3923828576
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      PLCDataReader/PublicMethod/BaseUtil.cs

+ 2 - 1
PLCDataReader/PublicMethod/BaseUtil.cs

@@ -412,8 +412,9 @@ namespace UAS_PLCDataReader.PublicMethod
                 HexStr = HexStr.Replace(":", "");
                 if (HexStr != "")
                 {
+                    int ValueDataSize = Convert.ToInt32("0x" + (HexStr.Substring(4, 2)), 16)*2;
                     string RealData = HexStr.Substring(6);
-                    RealData = RealData.Substring(0, RealData.Length - 2);
+                    RealData = RealData.Substring(0, ValueDataSize);
                     //每个地址位存的数据是DataSize个
                     for (int i = 0; i < RealData.Length; i = i + DataSize)
                     {