⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgque.h

📁 VC++ 串口通信的dll. MsgQue 和SerialBase中重要的数据结构和通信函数,其可以完全复用. SerialComm是具体的应用, 大家实际应用中要做相应的修改. 代码注释详细,书写规
💻 H
字号:
// MsgQue.h: interface for the MsgQue class.
//
//////////////////////////////////////////////////////////////////////
//File Name: MsgQue.h: implementation of the MsgQue and SafeMsgQue structure.
//References: MSDN
//Purpose: To implement a Safe Message Queue and some functions about it.

//History
//*Data          *Name      *comments.
//2008-Feb-03    Rock Li    Initialization

#if !defined(AFX_MSGQUE_H__28076F41_8497_451E_B1E2_8765051DF2AC__INCLUDED_)
#define AFX_MSGQUE_H__28076F41_8497_451E_B1E2_8765051DF2AC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma pack(1)
// message queue ;pragma pack(1) means align is 1 byte;
struct tag_MsgQue
{
	unsigned char Buf[256];
	struct tag_MsgQue* next;
} ;
#pragma pack()

typedef struct tag_MsgQue* pMsgQue;
typedef struct tag_MsgQue  MsgQue;
typedef struct tag_MsgQue  MsgNode;

struct tag_SafeMsgQue
{
	pMsgQue pMsg;         //Message queue
	pMsgQue pHead;        //the head of the Message queue
	pMsgQue pTail;		  //the tail of the Message queue	
	
	HANDLE hProExitEvn;   // program exit event; it should be passed by the caller.
	HANDLE hOpSem;        // Operation semaphore; 0/1 semaphore
	HANDLE hMsgSem;       // Message(s) exits. if there is one or more messages in the queue, the falg of hMsgSem is ture.
};

typedef struct tag_SafeMsgQue* pSafeMsgQue;
typedef struct tag_SafeMsgQue  SafeMsgQue;

bool SafeMsgQueInit(HANDLE hProExit, pSafeMsgQue pSafeQue);

bool ReadOneMsg(pMsgQue* pMsg, pSafeMsgQue pSafeQue);
bool InsertOneMsg(pMsgQue pMsg, pSafeMsgQue pSafeQue);

bool LockQue(pSafeMsgQue pSafeQue);
bool UnlockQue(pSafeMsgQue pSafeQue);

#endif // !defined(AFX_MSGQUE_H__28076F41_8497_451E_B1E2_8765051DF2AC__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -