浏览代码

添加KFP抄写接口。

JeffWang 2 年之前
父节点
当前提交
1c75df2a2e
共有 1 个文件被更改,包括 50 次插入0 次删除
  1. 50 0
      FactoryTool_CShare/IO/SerialCMD.cs

+ 50 - 0
FactoryTool_CShare/IO/SerialCMD.cs

@@ -2675,6 +2675,56 @@ namespace MOKA_Factory_Tools
             return false;
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="Comport"></param>
+        /// <param name="param"></param>
+        /// <param name="result"></param>
+        /// <param name="data"></param>
+        /// <param name="error"></param>
+        /// <param name="waitTime"></param>
+        /// <returns></returns>
+        public static bool SetKFPKey(SerialPort Comport, byte[] param, out byte[] result, out byte[] data, out string error, int waitTime)
+        {
+            return SendcmdEx(Comport, new byte[] { 0xAA, 0xFE }, new byte[] { 0xFC, 0x00, 0x15 }, param, false, false, out result, out data, out error, waitTime);
+        }
+
+        public static bool CheckKFPKey(SerialPort Comport, out byte[] result, out byte[] data, out string error, int waitTime)
+        {
+            if (SendcmdEx(Comport, new byte[] { 0xAA }, new byte[] { 0xFC }, new byte[] { 0x01, 0x15 }, true, false, out result, out data, out error, waitTime))
+            {
+                if (data.Length == 3 && data[0] == 0x02 && data[1] == 0x15 && data[2] == 0x01)
+                {
+                    return true;
+                }
+                else
+                {
+                    error = "检验 KFP Key 错误,应为0x02 0x15 0x01";
+                }
+            }
+
+            return false;
+        }
+
+        public static bool ReadKFPKey(SerialPort Comport, out byte[] result, out byte[] data, out string error, int waitTime)
+        {
+            if (SendcmdEx(Comport, new byte[] { 0xAA }, new byte[] { 0xFC }, new byte[] { 0x03, 0x15 }, true, true, out result, out data, out error, waitTime))
+            {
+                if (data[0] == 0x04 && data[1] == 0x15)
+                {
+                    data = data.Skip(2).Take(data.Length - 2).ToArray();
+                    return true;
+                }
+                else
+                {
+                    error = "返回KFP Key错误!";
+                }
+            }
+
+            return false;
+        }
+
         /// <summary>
         /// 通讯逻辑
         /// </summary>