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 | 387 ------------------------------------------------------- 1 files changed, 0 insertions(+), 387 deletions(-) diff --git a/ComLib/Inc/KBusDefine.h b/ComLib/Inc/KBusDefine.h index 6c191dc..d838eab 100644 --- a/ComLib/Inc/KBusDefine.h +++ b/ComLib/Inc/KBusDefine.h @@ -9,393 +9,6 @@ #ifndef __KBUSDEFINE_H__ #define __KBUSDEFINE_H__ -#define KBUS_VER (0x104) - -//#define SYN_PREFIX 1 - -typedef unsigned char uchar; - -enum enKBusStationType // KBus工作类型 -{ - KBNone = 0, // 0,未定义 - KBusMaster = 1, // 1,主机 - KBusSlave = 2, // 2,子机 - KBusRepeater = 3, // 3,转发器,中继器 -}; - -// diagnosis -enum enKBusStats -{ - KBusStatUnInited, // 未初始化状态 - KBusStatInited, // 已初始化状态 - KBusStatConfig, // 已配置状态 - KBusStatReady, // 就绪状态 - KBusStatRunning, // 运行状态 - KBusStatIdel, // 暂停状态 - KBusStatSafe, // 安全状态 - KBusStatError, // 错误状态 -}; -/* -enum enKBusStage -{ - KBusStageInit, - KBusStageFindChild, - KBusStageConfigChild, - KBusStagePoll, - -}; -*/ -enum { - KB_SYN = 0x55, - KBStartSign='%', - KBEndSign=0x0D, - KBMaxPacketLength=128, -}; - -enum enCMDs -{ - - cmdNone = 0x00, //Nothing - - cmdQuery = 0x01, //Query basic Info - cmdQueryRply = 0x81, //Query Info Reply - - cmdSetCfg = 0x02, // Set Configuration - cmdSetCfgRply = 0x82, // Set Configuration Response - - cmdToRunMode = 0x03, - cmdToRunModeRply = 0x83, - - cmdBroadCastCfg = 0x04, // - - cmdMuExchgData = 0x05, // - cmdMuExchgDataRply = 0x85, // - - cmdToSafeMode = 0x06, - - cmdHeartBeat = 0x07, // - cmdReHeartBeat = 0x87, // - - cmdPing = '1', //Ping - cmdPingReply = '2', //PingReply - cmdRead = '3', //Read - cmdReadReply = '4', //ReadReply - cmdWrite = '5', //Write - cmdWriteReply = '6', //WriteReply - cmdGetVersion = '7', //GetVersion - cmdVerInfo = '8', //VersionReply - - cmdUniExChgData='A', //ExChangeData, = Wirte + Read - cmdExChgDataReply, //ExchangeData Reply - - cmdSyncRead='a', //SyncRead - cmdSyncWrite, //SyncWrite - cmdSequenRead, //Sequence Read - cmdSyncTime, //SyncTime -}; - - - -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 // KBus 版本信息 -{ - unsigned char nMainVer; - unsigned char nSubVer; -}stVerInfo; - -typedef struct tagMasterStat // KBus 主机状态? -{ - unsigned int CycleTime; -} stMasterStat; - -typedef struct tagDeviceInfo // KBus 子机基本信息 -{ - unsigned short DeviceType; // 子机类型 - unsigned short DeviceVer; // 子机版本 - unsigned char InBitCount; // 输入开关量数量 - unsigned char OutBitCount; // 输出开关量数量 - unsigned char DWStartAddr; // 输出数据字数 - unsigned char OutDWCount; // 输出数据字数 - unsigned char AIWCount; // 输入模拟量通道(字)数 // 16位为一个字(通道) - unsigned char AQWCount; // 输出模拟量通道(字)数 // 16位为一个字(通道) -// unsigned char AIBits; // 每通道位数 // 16位以下 -// unsigned char AQbits; // 每通道位数 // 16位以下 - - -}stDeviceInfo; - -typedef struct tagExDeviceInfo // 子机扩展信息 -{ - unsigned short DeviceType; // 子机类型 - unsigned short DeviceVer; // 子机版本 - - unsigned char UID[12]; // 12字节 UUID - unsigned char Name[16]; // 16字节 名称 -// stVerInfo ClientVer; - unsigned char InBitCount; - unsigned char OutBitCount; - unsigned char DWStartAddr; - unsigned char OutDWCount; - unsigned char AIWCount; - unsigned char AQWCount; -// unsigned char AIBits; -// unsigned char AQbits; - - -}stExDeviceInfo; - -enum enKBusConfigStat -{ - KBusUnConfiged = 0, - KBusDefaultConfiged =1, - KBusConfiged = 2, -}; - -typedef struct tagClientCfg // 子机配置 -{ - unsigned char Addr; // 子机地址 - unsigned char Configed; // 是否已配置 - unsigned char bOnline; //当前在线状态 - unsigned char InStartAddrBit; //输入起始位地址 - unsigned char OutStartAddrBit; //输出起始位地址 - unsigned char AIWStartAddrByte; //模拟入起始字地址 - unsigned char AQWStartAddrByte; //模拟出起始字地址 - unsigned char DIWStartAddrByte; //数据入起始字地址 - unsigned char DOWStartAddrByte; //数据出起始字地址 - unsigned char 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 short Stat; - unsigned short SendPackets; - unsigned short RecvPackets; - unsigned short LastSentTimeuS; - unsigned short LostPackets; - unsigned short CtnLstPkts; - unsigned short MaxCtnLstPkts; - unsigned short NotPkgErr; - unsigned short PkgLenErr; - unsigned short BCCErr; - unsigned short TimeOutErr; - unsigned short Delay; - unsigned short MaxDelay; - unsigned short SendTimeInterval; - union - { - unsigned short ClientDatas[10]; - struct { - unsigned short ClientRecvPkts; // - unsigned short ClientSendPkts; // - unsigned short ClientNotPktErr; // - unsigned short ClientMisIdPkts; // -// unsigned int ClientNoEndErr; // - unsigned short ClientPkgLenErr; // - unsigned short ClientBccErr; // - unsigned short 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; - -enum eResult -{ - S_OK =0, - S_ERR=1, - S_TIMEOUT=2 - -} ; - -/* -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; -*/ - -enum enumCallBackEvent -{ - KBusEvNone = 0, - KBusEvCreate = 1, - KBusEvConnected = 2, - KBusEvDisConnected = 3, - KBusEvClosed = 4, - KBusEvStateChange =5, - KBusEvTimeSync=6, - KBusEvDataUpdate =7, - KBusEvCmdResponse = 8, - -}; - -typedef int (*KBusSendPktFuncDef) (uchar * pBuf, int nLen); // SendPacket CallBack func for KBus - -typedef void *(*KBusEvCBFuncDef) (void * , int nEvent, void *, int); //callback func ,prama s is void *,void *,int; return void *; - -typedef int (*KBusSvCBFuncDef) (void *, int nSvType, int ,void *, int); //Service Req callback func ,param is int ,int, int, void *,int; return int; #endif /* __KBUSDEFINE_H__ */ -- Gitblit v1.9.1