www.pudn.com > IEC104_codeamaterial.rar > pcol.h, change:2010-09-21,size:1458b


/*------------------------------------------------------------------------ 
 Module:		pcol.h 
 Author:		solar 
 Project:		pas300m 
 State: 		 
 Creation Date: 2005-10-17 
 Description:	 
------------------------------------------------------------------------*/ 
/*------------------------------------------------------------------------ 
 $Log: $ 
 ------------------------------------------------------------------------*/ 
#ifndef _PCOL_H 
#define _PCOL_H 
 
#include "mytypes.h" 
 
#define PCOLCOMMBUFLEN	 128 
 
#define PCOL_FRAME_SHIELD   0xFFFF0000	    
#define PCOL_FRAME_OK	    0x00010000	    
#define PCOL_FRAME_ERR	    0x00020000	    
#define PCOL_FRAME_LESS	    0x00030000	    
 
typedef struct 
{ 
	WORD   wReadPtr;						 
	WORD   wWritePtr;						 
	BYTE   *pBuf;			 
}VPcolCommBuf; 
 
typedef struct 
{ 
    int nId;	 
	BOOL bHaveRxFrm; 
	VPcolCommBuf Rec; 
	VPcolCommBuf RecFrm; 
	VPcolCommBuf Send; 
 
	void (*ProcFrm)(void *arg);	 
	DWORD (*SearchOneFrame)(BYTE *Buf, int Len); 
}VPcol;	 
 
__inline__ BYTE Lrc(BYTE *p, int l) 
{ 
    BYTE k = 0; 
    int j; 
 
	for(j=0; j<l; j++) 
        k=k^p[j]; 
	 
	return (k); 
} 
 
BYTE Bch(BYTE *p, int l); 
 
void PcolInit(int tid, VPcol *pcol, void (*ProcFrm)(void *), DWORD (*SearchOneFrame)(BYTE *, int)); 
void NeatenCommBuf(VPcolCommBuf *pCommBuf); 
int DoReceive(VPcol *pCol); 
void ProcData(VPcol *pCol); 
BOOL SearchFrame(VPcol *pCol); 
void DoSend(VPcol *pCol, DWORD wFlag); 
 
#endif