ProtocolModbus.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // ProtocolPMC916.h: interface for the CProtocolModbus class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PROTOCOLPMC916_H__3A4B4E9B_C165_4415_8EC3_3F5AA66B53C9__INCLUDED_)
  5. #define AFX_PROTOCOLPMC916_H__3A4B4E9B_C165_4415_8EC3_3F5AA66B53C9__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #define DEBUG_PROTOCOL 1
  10. #include "Protocol.h"
  11. class CProtocolModbus : public CProtocol
  12. {
  13. public:
  14. virtual BOOL InitParam(PPORTPARAM pPortParam, CCommAsyn *pComm);
  15. virtual int WorkMain( int nCommPort,
  16. int nAddr,
  17. char szCmd[32],
  18. char chSendMsg[32],
  19. int nDataLen,
  20. char chMsg[UPS_KE_HUA_MAX_MSG]);
  21. virtual int WriteCommand(char DataBuffer[80], int nDataLen);
  22. CProtocolModbus();
  23. virtual ~CProtocolModbus();
  24. protected:
  25. HANDLE m_hSemComm;
  26. CRITICAL_SECTION m_csReadFinished;
  27. CRITICAL_SECTION m_csWrFinished;
  28. protected:
  29. virtual int RequestStatus(char chSendMsg[32]);
  30. virtual int ResponseStatus(char szCmd[32], int nDataLen, char chMsg[UPS_KE_HUA_MAX_MSG]);
  31. virtual int RequestWrStatus( char DataBuffer[80], int nDataLen);
  32. virtual int ResponseWrStatus(char DataBuffer[80], int nDataLen);
  33. };
  34. //BYTE GetCheckCode(const char * pSendBuf, int nEnd);//»ñµÃУÑéÂë
  35. char ByteToAscii(BYTE btSrc);
  36. WORD AsciiToBYTE(BYTE btSrc);
  37. static unsigned char LRC(unsigned char *auchMsg, unsigned short usDataLen);
  38. #endif // !defined(AFX_PROTOCOLPMC916_H__3A4B4E9B_C165_4415_8EC3_3F5AA66B53C9__INCLUDED_)