MsgQueue.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /********************************************************************************
  2. * File Name: MsgQueue.h
  3. * Function Describe: Header file for MsgQueue.c
  4. * Explain:
  5. * Writer: ShiLiangWen
  6. * Date: 2015-6-29
  7. *******************************************************************************/
  8. #ifndef __MSG_QUEUE_H
  9. #define __MSG_QUEUE_H
  10. /************************************file begin*******************************/
  11. #define MSG_QUEUE_NUM_MAX 10 //每个消息队列允许最大消息数
  12. //消息结构体
  13. typedef struct{
  14. unsigned short MsgLen;//消息数据长度
  15. unsigned short DataStartIndex;//消息数据在数据缓冲区中的开始位置索引
  16. }SUT_MESSAGE;
  17. //消息队列结构体
  18. typedef struct{
  19. unsigned short MsgIn;//加入新消息的位置索引
  20. unsigned short MsgOut;//取出已有消息的位置索引
  21. unsigned short MsgNum;//当前消息个数
  22. SUT_MESSAGE MsgQueue[MSG_QUEUE_NUM_MAX];//消息队列
  23. //--数据缓冲区
  24. unsigned short DataBufferLenMax;
  25. unsigned short DataBufferLen;
  26. unsigned short DataBufferIn;
  27. unsigned short DataBufferOut;
  28. char *DataBuffer;//数据缓冲区
  29. }SUT_MSG_QUEUE;
  30. void MsgQueueInit(SUT_MSG_QUEUE *pMsgQueue,char *pDataBuffer,unsigned short DataBufferLenMax);
  31. void MsgQueuePost(SUT_MSG_QUEUE *pMsgQueue,char *pData,unsigned short DataLen);
  32. int MsgQueueAccept(SUT_MSG_QUEUE *pMsgQueue,char *pBuf,unsigned short BufLen);
  33. void MsgQueuePostLoopBuf(SUT_MSG_QUEUE *pMsgQueue,char *pLoopBuf,unsigned short LoopDataBufLen,unsigned short LoopDataStart,unsigned short DataLen);
  34. /************************************file end*******************************/
  35. #endif