From eea0893be9d4ef175ab26e8fea51d41fa33477ce Mon Sep 17 00:00:00 2001
From: Yao Chunli <56721587@qq.com>
Date: 星期六, 28 五月 2022 08:20:57 +0800
Subject: [PATCH] change eventlog

---
 MTerm2/KLink.h |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/MTerm2/KLink.h b/MTerm2/KLink.h
index 8cdfb8f..de83e9d 100644
--- a/MTerm2/KLink.h
+++ b/MTerm2/KLink.h
@@ -196,8 +196,10 @@
 	KLCmdResetMachine,
 	KLCmdGetUid,
 	KLCmdSetTime,
+	KLCmdGetSN,
 
-	KLCmdMC,
+
+	KLCmdMC = 0x70, 
 	KLCmdMD,
 	KLCmdMG,
 
@@ -543,6 +545,9 @@
 		for (int i = 0; i < ReTryCount; i++)
 		{
 			int len1= RecvPkgFunc(pBufByte + len2, LenToRead - len2);
+			if (len1 <= 0 || len1 > 256) {
+				continue;
+			}
 			len2 += len1;
 			if (len2 >= LenToRead) break;
 		}
@@ -580,9 +585,12 @@
 int ProcessPacket(void *pBuf, int nLen);
 int ParseRplyPacket(void *pBuf, int nPkgLen, UCHAR * nCmd, UCHAR * Status, USHORT* nCount, void * pData);
 
-int GetInfo(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT * Values);
-int GetSN(UCHAR nDst, int * nCount);
-int GetUID(UCHAR nDst, int * nCount);
+int GetInfo(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+int GetSN(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+int GetUID(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+int GetFactoryData(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+int WriteFactoryData(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+
 //int GetTime32(UCHAR nDst, int * nCount);
 //int SetTime32(UCHAR nDst, int * nCount);
 int GetDateTime32(UCHAR nDst, UINT * pValue);
@@ -595,19 +603,19 @@
 
 int ReadBit(UCHAR nDst, UCHAR nType,USHORT nBitAddr, UCHAR * Value);//Read 1 Single bit
 int WriteBit(UCHAR nDst, UCHAR nType,USHORT nBitAddr, UCHAR Value);//Write 1 Single bit
-int ReadBits(UCHAR nDst, UCHAR nBitCount, UCHAR nType, USHORT nBitAddr, UCHAR * Values);
-int WriteBits(UCHAR nDst, UCHAR nBitCount, UCHAR nType, USHORT nBitAddr, UCHAR * Values);
-int ReadBitsByWord(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT *Values);
-int WriteBitsByWord(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT *Values);
+int ReadBits(UCHAR nDst,  UCHAR nType, USHORT nBitAddr, UCHAR nBitCount, UCHAR * Values);
+int WriteBits(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR nBitCount, UCHAR * Values);
+int ReadBitsByWord(UCHAR nDst,  UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT *Values);
+int WriteBitsByWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT *Values);
 
-int ReadDataByte(UCHAR nDst, UCHAR nByteCount, UCHAR nType, USHORT nByteAddr, UCHAR * Values);
-int WriteDataByte(UCHAR nDst, UCHAR nByteCount, UCHAR nType, USHORT nByteAddr, UCHAR * Values);
+int ReadDataByte(UCHAR nDst,  UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR * Values);
+int WriteDataByte(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR * Values);
 
-int ReadDataWord(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT * Values);
-int WriteDataWord(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT * Values);
+int ReadDataWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+int WriteDataWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
 
-int ReadData(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT * Values);
-int WriteData(UCHAR nDst, UCHAR nWordCount, UCHAR nType, USHORT nWordAddr, USHORT * Values);
+int ReadData(UCHAR nDst,  UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
+int WriteData(UCHAR nDst,  UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
 
 int GetMode(UCHAR nDst, UCHAR nType);
 int ChangeMode(UCHAR nDst,  UCHAR nType);

--
Gitblit v1.9.1