From 9aed5d7e7b3c7bf09da712e9c272ece401a7acc9 Mon Sep 17 00:00:00 2001 From: QuakeGod <QuakeGod@sina.com> Date: 星期一, 25 十一月 2024 14:51:23 +0800 Subject: [PATCH] add UltraSonic and MultiWireLess --- ComLib/Inc/KBusDefine.h | 314 ---------------------------------------------------- 1 files changed, 0 insertions(+), 314 deletions(-) diff --git a/ComLib/Inc/KBusDefine.h b/ComLib/Inc/KBusDefine.h index 70623ad..d838eab 100644 --- a/ComLib/Inc/KBusDefine.h +++ b/ComLib/Inc/KBusDefine.h @@ -9,320 +9,6 @@ #ifndef __KBUSDEFINE_H__ #define __KBUSDEFINE_H__ -#define KBUS_VER (0x104) - -//#define SYN_PREFIX 1 - -typedef unsigned char uchar; - -enum enKBusStationType -{ - KBNone = 0, - KBusMaster = 1, - KBusSlave = 2, - KBusRepeater = 3, -}; - -// diagnosis -enum enKBusStats -{ - KBusStatIdel, - KBusStatConfig, - KBusStatRunning, - KBusStatError, -}; - -enum enCMDs -{ - cmdNone = '0', //Nothing - cmdPing = '1', //Ping - cmdPingReply = '2', //PingReply - cmdRead = '3', //Read - cmdReadReply = '4', //ReadReply - cmdWrite = '5', //Write - cmdWriteReply = '6', //WriteReply - cmdGetVersion = '7', //GetVersion - cmdVerInfo = '8', //VersionReply - - cmdExChgData='A', //ExChangeData, = Wirte + Read - cmdExChgDataReply, //ExchangeData Reply - - cmdSyncRead='a', //SyncRead - cmdSyncWrite, //SyncWrite - cmdSequenRead, //Sequence Read - cmdSyncTime, //SyncTime -}; - -enum { - SYN = 0x55, - StartSign='%', - EndSign=0x0D, - MaxPacketLength=128, -}; - -typedef struct tagKBusRunStat -{ - unsigned char bMaster; - unsigned char nStationID; - unsigned char nChildren; - unsigned char nCurPollId; - unsigned char nSeq; - - unsigned char bMasterRecved; - unsigned char bMasterRecvOK; - unsigned char bSlaveRecved; - unsigned int nSendTimeuS; - -}stKBusRunStat , * pstKBusRunStat; - -typedef struct tagVerInfo -{ - unsigned char nMainVer; - unsigned char nSubVer; -}stVerInfo; - -typedef struct tagMasterStat -{ - unsigned int CycleTime; -} stMasterStat; - -typedef struct tagClientInfo -{ - unsigned short ClientType; - unsigned short ClientVer; -// stVerInfo ClientVer; - unsigned char InBitCount; - unsigned char OutBitCount; - unsigned char AICount; - unsigned char AIBits; - unsigned char AQCount; - unsigned char AQbits; - unsigned char InDWCount; - unsigned char OutDWCount; - unsigned char bOnline; -}stClientInfo; - - -typedef struct tagClientCfg -{ - unsigned char nGroup; - unsigned char Addr; - unsigned char InStartAddrBit; - unsigned char OutStartAddrBit; - unsigned char InAWStartAddrByte; - unsigned char OutAWStartAddrByte; - unsigned char InDWStartAddrByte; - unsigned char OutDWStartAddrByte; - unsigned int KeepOut; //Keep Output when comm err; -}stClientCfg; - -typedef struct ServerStatus -{ - unsigned char Addr; - unsigned char Status; - unsigned short Input[16]; - unsigned short DT[128]; - unsigned short output[16]; - -}stServerStatus,*pServerStatus; - -typedef struct tagMachineState -{ - unsigned char Addr; - unsigned char state; - unsigned char InStartAddrBit; - unsigned char OutStartAddrBit; - unsigned char InDWStartAddrByte; - unsigned char OutDWStartAddrByte; -}ClientState; - - - -#pragma anon_unions -typedef struct tagChnStat -{ - unsigned int Stat; - unsigned int SendPackets; - unsigned int RecvPackets; - unsigned int LastSentTimeuS; - unsigned int LostPackets; - unsigned int CtnLstPkts; - unsigned int MaxCtnLstPkts; - unsigned int NotPkgErr; - unsigned int PkgLenErr; - unsigned int BCCErr; - unsigned int TimeOutErr; - unsigned int Delay; - unsigned int MaxDelay; - unsigned int SendTimeInterval; - union - { - unsigned int ClientDatas[10]; - struct { - unsigned int ClientRecvPkts; // - unsigned int ClientSendPkts; // - unsigned int ClientNotPktErr; // - unsigned int ClientMisIdPkts; // -// unsigned int ClientNoEndErr; // - unsigned int ClientPkgLenErr; // - unsigned int ClientBccErr; // - unsigned int ClientTimeOutErr; // - }; - }; -} stChnStat; - - -typedef struct tagSlaveStat -{ - unsigned int nSlaveTick; -} stSlaveStat; - -typedef struct ServerClientListElement -{ - unsigned char Addr; - unsigned char Status; - unsigned char Father; - unsigned char Childs; - -} stServerClientListElement; - -typedef struct ServerClientList -{ - unsigned char Addr; -}stServerClientList,*pServerClientList; - -typedef struct tagMachineConfig -{ - int bKBusMaster; - int nAddr; -}stMachineConfig; - -/* -typedef struct ClientStatus -{ - unsigned char Addr; - unsigned char Status; - unsigned char Father; - unsigned char Childs; - unsigned short Input[16]; - unsigned short DT[128]; - unsigned short output[16]; - -}stChnStatus,*pClientStatus; -*/ - -typedef struct tagStatusDef -{ - unsigned char nSeq:2; //序列号 - unsigned char :2; - unsigned char nErr1:1; - unsigned char nErr2:1; -}stStatus; - -typedef union tagUnStatusDef -{ - unsigned char nStatus; - stStatus; -}unStatus; - -typedef struct tagKBPacket -{ - unsigned char Sign; //起始标记 - unsigned char DstHost; //目标地址 - unsigned char SrcAddr; //源地址 - unsigned char nCMD; //命令 - union{ - unsigned char nStatus; //状态+序列号 - struct{ - unsigned char nSeq:2; //序列号 - unsigned char :2; - unsigned char nErr1:1; - unsigned char nErr2:1; - - }; - }; - unsigned char DataLen; //数据载荷长度 不包括头部5个字节,不包括尾部BCC。 - unsigned char data[1]; //数据载荷,最末尾是BCC,数据长度为0时,实际也有一个数据。 -}stKBPacket,* pKBPacket; - -typedef struct tagKBInfoBlockV1 -{ - unsigned short nDeviceType; - unsigned short nProgVer; - - unsigned char InBitCount; - unsigned char OutBitCount; - - unsigned char AICount; - unsigned char AIBits; - unsigned char AQCount; - unsigned char AQbits; - - unsigned char InDWCount; - unsigned char OutDWCount; - -}stKBInfoBlockV1, *pKBInfoBlockV1; - - -/* -typedef struct tagKBPacketV10 -{ - unsigned char Sign; //起始标记 - unsigned char DstHost; //目标地址 - unsigned char SrcAddr; //源地址 - unsigned char nCMD; //命令 - union{ - unsigned char nStatus; //状态+序列号 - struct{ - unsigned char nSeq:2; //序列号 - unsigned char :2; - unsigned char nErr1:1; - unsigned char nErr2:1; - - }; - }; - unsigned char DataLen; //数据载荷长度 不包括头部5个字节,不包括尾部BCC。 - unsigned char data[1]; //数据载荷,最末尾是BCC,数据长度为0时,实际也有一个数据。 -}stKBPacketV10,* pKBPacketV10; - -typedef struct tagKBPacketV20 -{ - unsigned char Sign; //起始标记 - unsigned char DstHost; //目标地址 - unsigned char SrcAddr; //源地址 - unsigned char nCMD; //命令 - union{ - unsigned char nStatus; //状态+序列号 - struct{ - unsigned char nSeq:2; //序列号 - unsigned char :2; - unsigned char nErr1:1; - unsigned char nErr2:1; - - }; - }; - unsigned char DataLen; //数据载荷长度 不包括头部5个字节,不包括尾部BCC。 - unsigned char data[1]; //数据载荷,最末尾是BCC,数据长度为0时,实际也有一个数据。 -}stKBPacketV20,* pKBPacketV20; -*/ -typedef void *(*CBFuncDef) (void*, void *, int); //callback func ,prama s is void *,void *,int; return void *; - -enum eResult -{ - S_OK =0, - S_ERR=1, - S_TIMEOUT=2 - -} ; - -enum enumCallBackEvent -{ - evNone = 0, - evCreate = 1, - evConnected = 2, - evDisConnected = 3, - evClosed = 4, -}; #endif /* __KBUSDEFINE_H__ */ -- Gitblit v1.9.1