|
@@ -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>
|