From 6126f6a78b14297cefb02f06ba58806767d424b5 Mon Sep 17 00:00:00 2001 From: QuakeGod <QuakeGod@sina.com> Date: 星期三, 01 二月 2023 12:05:29 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/FP0' into kNet --- Inc/KLink.h | 115 ++++++++++++++++++--------------------------------------- 1 files changed, 37 insertions(+), 78 deletions(-) diff --git a/Inc/KLink.h b/Inc/KLink.h index ea4bd0e..20a10ef 100644 --- a/Inc/KLink.h +++ b/Inc/KLink.h @@ -28,8 +28,8 @@ } ; -enum {KLSignStart='%', - KLSignReply='U', +enum {KLSignStart='%', //0x25 + KLSignReply='U', //0x55 KLSignEnd=0x0D, KLMaxPacketLength=64, }; @@ -61,7 +61,9 @@ KLCmdSetPass, KLCmdEraseAll, KLCmdReadProgram, + KLCmdStartProgram, KLCmdWriteProgram, + KLCmdFinishProgram, KLCmdRead1Bit = 0x21, //ReadSingleBit KLCmdWrite1Bit = 0x22, //WriteSingleBit @@ -83,6 +85,8 @@ KLCmdReadData = 0x35, KLCmdWriteData = 0x36 , + KLCmdStopBlinkLED = 0x4F, + KLCmdBlinkLED = 0x50, KLCmdReadProg = 0x51, KLCmdWriteProg, @@ -90,6 +94,8 @@ KLCmdWriteSysCfg, KLCmdSaveSysCfg, KLCmdSaveRunStat, + KLCmdReadRunStat, + KLCmdClearRunStat, KLCmdEraseFlashPage = 0x61, KLCmdWriteToFlash = 0x62, @@ -102,8 +108,11 @@ KLCmdResetMachine, KLCmdGetUid, KLCmdSetTime, - - KLCmdMC, + KLCmdGetSN, + KLCmdReadFactData, + KLCmdWriteFactData, + + KLCmdMC = 0x70, KLCmdMD, KLCmdMG, @@ -119,63 +128,13 @@ KLInfoTypeEventLogCount = 3, }; - enum enKLCoilTypes - { - KLCoilTypeX = 0, //X Input - KLCoilTypeY = 1, //Y Output - KLCoilTypeR = 2, //R register - KLCoilTypeLX = 3, //Link register - KLCoilTypeLY = 4, //Link register - KLCoilTypeT = 5, //Timer - KLCoilTypeC = 5, //Counter - KLCoilTypeLR = 6, //Link register - - }; - enum enKLDataTypes - { - KLDataTypeWX = 0, - KLDataTypeWY = 1, - KLDataTypeWR = 2, - KLDataTypeWLX = 3, - KLDataTypeWLY = 4, - KLDataTypeDT = 5, - KLDataTypeSDT = 6, - KLDataTypeWSR = 7, - KLDataTypeSV = 8, - KLDataTypeEV = 9, - KLDataTypeLD = 10, - - KLDataSysCfg = 25, - KLDataTypeFlash = 33 , - - KLDataTypeTest = 254, - }; -enum enKLDataCounts -{ - KLCoilXCount=256, - KLCoilYCount=256, - KLCoilRCount=256, - KLCoilTCount=64, - KLCoilCCount=64, - KLCoilLCount=128, - KLDataDTCount = 256, - KLDataSDTCount = 256, - KLDataWXCount = 16, - KLDataWYCount = 16, - KLDataWRCount = 16, - KLDataSVCount = 64, - KLDataEVCount = 64, - KLDataLDCount = 64, - KLDataWLCount = 8, -}; - extern unsigned char KLPacketBuf1[256]; extern unsigned char KLPacketBuf2[256]; extern unsigned char KLBufferIn[16]; extern unsigned char KLBufferOut[16]; -extern unsigned char nKLAddr; +extern unsigned char nKLStationId; extern unsigned char nKLSeq; extern int KLThisuS; @@ -204,7 +163,7 @@ typedef struct tagKLReqPktHdr { unsigned char ReqStSgn; // - unsigned char DstAddr; // + unsigned char DstHost; // unsigned char Stat; // unsigned char nCMD; // unsigned char nType1; // @@ -214,7 +173,7 @@ typedef struct tagKLPingReqPkt { unsigned char ReqStSgn; // - unsigned char DstAddr; // + unsigned char DstHost; // unsigned char nCMD; // unsigned char nSize; // @@ -223,7 +182,7 @@ typedef struct tagKLRplyPktHdr { unsigned char RplyStSgn; // - unsigned char DstAddr; // + unsigned char DstHost; // unsigned char nStatus; // unsigned char nRplyCMD; // unsigned char nSize1; // @@ -233,20 +192,20 @@ /* typedef struct tagKLPktHdr { - unsigned char StSign; //起始标记 - unsigned char SrcAddr; //源地址 - unsigned char DstAddr; //目标地址 - unsigned char nCMD; //命令 + unsigned char StSign; //璧峰鏍囪 + unsigned char SrcAddr; //婧愬湴鍧� + unsigned char DstHost; //鐩爣鍦板潃 + unsigned char nCMD; //鍛戒护 }stKLPtHdr, * pKLPktHdr; */ /* typedef struct tagKLRdPkt { - unsigned char StSign; //起始标记 - unsigned char SrcAddr; //源地址 - unsigned char DstAddr; //目标地址 - unsigned char nCMD; //命令 + unsigned char StSign; //璧峰鏍囪 + unsigned char SrcAddr; //婧愬湴鍧� + unsigned char DstHost; //鐩爣鍦板潃 + unsigned char nCMD; //鍛戒护 unsigned char nType; unsigned char nAddr; // }stKLRdPkt,* pKLRdKpt; @@ -254,28 +213,28 @@ /* typedef struct tagKLPacket { - unsigned char StSign; //起始标记 - unsigned char SrcAddr; //源地址 - unsigned char DstAddr; //目标地址 - unsigned char nCMD; //命令 - unsigned char nSEQ; //序列号 - unsigned char LoadLen; //数据载荷长度 不包括头部5个字节,不包括尾部BCC。 - unsigned char data[1]; //数据载荷,最末尾是BCC,数据长度为0时,实际也有一个数据。 + unsigned char StSign; //璧峰鏍囪 + unsigned char SrcAddr; //婧愬湴鍧� + unsigned char DstHost; //鐩爣鍦板潃 + unsigned char nCMD; //鍛戒护 + unsigned char nSEQ; //搴忓垪鍙� + unsigned char LoadLen; //鏁版嵁杞借嵎闀垮害 涓嶅寘鎷ご閮�5涓瓧鑺傦紝涓嶅寘鎷熬閮˙CC銆� + unsigned char data[1]; //鏁版嵁杞借嵎,鏈�鏈熬鏄疊CC锛屾暟鎹暱搴︿负0鏃讹紝瀹為檯涔熸湁涓�涓暟鎹�� }stKLPacket,* pKLPacket; */ -unsigned char KLBCC(void * pData, int nSize); +unsigned char KLBCC(const void * pData, int nSize); // /* Make a Packet and return Packet Length */ -int KLMakeReqPacket(void * pBuf1,uchar Src, uchar Dst, uchar nType, uchar nSEQ, uchar DataLen, void *pData ); -int KLMakeRplyPacket(void * pBuf1, uchar Dst, uchar Status, uchar nCmd, uchar DataLen, void *pData ); +int KLMakeReqPacket(void * pBuf1, uchar Src, uchar Dst, uchar nType, uchar nSEQ, uchar DataLen, void *pData ); +int KLMakeRplyPacket(void * pBuf1, uchar Dst, uchar Status, uchar nCmd, uchar DataLen, const void *pData ); /* */ -int KLCheckPacket(void * pBuf1,int len1); +int KLCheckPacket(int nChn, void * pBuf1, int len1); /* */ -int KLParsePacket(void * pBuf1, int Len1); +int KLParsePacket(int nChn, void * pBuf1, int Len1); //int ReadData(void); -- Gitblit v1.9.1