// Protocol.cpp: implementation of the CProtocol class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Protocol.h" #include "CommAsyn.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CProtocol::CProtocol() { m_pComm=NULL; memset( &m_structResponse, 0, sizeof(RESPONSE_STRUCT) ); } CProtocol::~CProtocol() { } int CProtocol::ReadMessage(BYTE *pBuf, int len) { if( !AfxIsValidAddress(pBuf, len, FALSE ) ) return 0; if( !m_pComm ) return 0; if( !::AfxIsValidAddress(m_pComm, sizeof(CCommAsyn), FALSE ) ) { return 0; } int iResult=m_pComm->Read(pBuf,len); if(iResult>len) iResult=len; return iResult; } int CProtocol::WriteMessage(BYTE *pBuf, int len) { if( !m_pComm ) return 0; if( !::AfxIsValidAddress(m_pComm, sizeof(CCommAsyn), FALSE ) ) { return 0; } int iResult = m_pComm->Write(pBuf,len); return iResult; } BOOL CProtocol::InitParam(PPORTPARAM pPortParam, CCommAsyn *pComm) { return FALSE; }