/******************************************************************************** * File Name: MsgQueue.h * Function Describe: Header file for MsgQueue.c * Explain: * Writer: ShiLiangWen * Date: 2015-6-29 *******************************************************************************/ #ifndef __MSG_QUEUE_H #define __MSG_QUEUE_H /************************************file begin*******************************/ #define MSG_DATA_BUF_LEN (6*1024) //消息数据缓冲区最大长度,此数据缓冲区将被多个消息队列共用 #define MSG_QUEUE_NUM_MAX 50 //每个消息队列允许最大消息数 //消息结构体 typedef struct{ unsigned short MsgLen;//消息数据长度 unsigned short DataStartIndex;//消息数据在数据缓冲区中的开始位置索引 }SUT_MESSAGE; //消息队列结构体 typedef struct{ unsigned short MsgIn;//加入新消息的位置索引 unsigned short MsgOut;//取出已有消息的位置索引 unsigned short MsgNum;//当前消息个数 SUT_MESSAGE MsgQueue[MSG_QUEUE_NUM_MAX];//消息队列 //--数据缓冲区 unsigned short DataBufferLenMax; unsigned short DataBufferLen; unsigned short DataBufferIn; unsigned short DataBufferOut; char *DataBuffer;//数据缓冲区 }SUT_MSG_QUEUE; extern SUT_MSG_QUEUE msgQue; void MsgQueueInit(char *pDataBuffer,unsigned short DataBufferLenMax); int MsgQueuePost(char *pData,unsigned short DataLen); int MsgQueueAccept(char *pBuf,unsigned short BufLen); void MsgQueueSet(void); /************************************file end*******************************/ #endif