Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.4 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT: Laserguard libraries
  7. // SUBSYSTEM: Communication support library
  8. // FILE: ProtLGSm.h
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of CProtocolLGS
  13. //----------------------------------------------------------------------------
  14. #ifndef __PROTOCOL__MULTI__H__INCLUDED__
  15. #define __PROTOCOL__MULTI__H__INCLUDED__
  16. #ifdef __BORLANDC__
  17. #include "..\lglib\Comm\connect.h"
  18. #include "..\lglib\Comm\protocol.h"
  19. #else
  20. #include "connect.h"
  21. #include "protocol.h"
  22. #endif
  23. class CProtocolLGS : public CProtocol
  24. {
  25. public:
  26. CProtocolLGS();
  27. ~CProtocolLGS();
  28. public:
  29. BOOL Create( CConnection *pCommPort );
  30. void Destroy();
  31. public:
  32. virtual BOOL Write( PBYTE pBuffer, INT nCount, DWORD dwTimeout, BOOL bHost );
  33. virtual BOOL Read( PBYTE *ppBuffer, PINT pCount, DWORD dwTimeout, BOOL bHost );
  34. public:
  35. enum
  36. {
  37. HEADER_POS = 0U, // position of header byte
  38. LENGTH_POS = 1U, // position of data length byte
  39. LENGTH_MASK = 0x7FU, // position of data length byte
  40. DATA_POS = 2U, // position of first data byte
  41. HEADER_SIZE = 2U, // header + length byte
  42. MIN_COMMAND_SIZE = 3U, // header + length byte + checksumm byte
  43. MAX_DATA_LENGTH = 60U, // maximun data size
  44. MAX_COMMAND_SIZE = (MAX_DATA_LENGTH + MIN_COMMAND_SIZE), // command,length,data0..dataN,checksum (N < 32)
  45. HEADER_TAG = 0x55,
  46. HOST_TAG = 0x80,
  47. };
  48. private:
  49. CConnection *m_pConnection;
  50. BYTE m_pBuffer[ MAX_COMMAND_SIZE ];
  51. PBYTE m_pBufferPtr;
  52. INT m_nCount;
  53. };
  54. /*
  55. class CLgProtocolPipe
  56. {
  57. public:
  58. CLgProtocolPipe();
  59. ~CLgProtocolPipe();
  60. public:
  61. BOOL PipeWrite( PBYTE pBuffer, INT nCount );
  62. BOOL PipeRead( PBYTE pBuffer, INT nCount );
  63. protected:
  64. virtual BOOL OnPipeWrite( PBYTE pBuffer, INT nWritten ) = 0;
  65. virtual BOOL OnPipeRead( PBYTE pBuffer, INT nRead ) = 0;
  66. public:
  67. enum{ MAX_BUFFER_SIZE = 2048 };
  68. BOOL Create( INT nBufferSize = MAX_BUFFER_SIZE );
  69. void Destroy();
  70. public:
  71. BOOL SubWrite( PBYTE pBuffer, INT nSubSize, PINT pWritten, BOOL bHost );
  72. BOOL SubRead( PBYTE pBuffer, INT nSubSize, PINT pRead, BOOL bHost );
  73. private:
  74. enum LG_E_PIPE_OPERATION{ LG_PIPE_OP_READ, LG_PIPE_OP_WRITE, LG_PIPE_OP_NONE };
  75. LG_E_PIPE_OPERATION m_eOperation;
  76. private:
  77. LPBYTE m_pBuffer;
  78. INT m_nBufferSize;
  79. private:
  80. INT m_nPosition;
  81. INT m_nRemain;
  82. BYTE m_nOrder;
  83. INT m_nLastSize;
  84. private:
  85. enum
  86. {
  87. LG_PIPE_SEND_CMD = 0,
  88. LG_PIPE_SEND_EVT = 1,
  89. LG_PIPE_RECEIVE_CMD = 2,
  90. LG_PIPE_RECEIVE_EVT = 3,
  91. };
  92. typedef struct
  93. {
  94. BYTE nOrder;
  95. BYTE nLast;
  96. WORD nPosition;
  97. BYTE nSize;
  98. }LG_PIPE_SEND_CMD_DATA;
  99. typedef struct
  100. {
  101. BYTE nOrder;
  102. WORD nPosition;
  103. }LG_PIPE_SEND_EVT_DATA;
  104. typedef struct
  105. {
  106. BYTE nOrder;
  107. WORD nPosition;
  108. }LG_PIPE_RECEIVE_CMD_DATA;
  109. typedef struct
  110. {
  111. BYTE nOrder;
  112. BYTE nLast;
  113. WORD nPosition;
  114. BYTE nSize;
  115. }LG_PIPE_RECEIVE_EVT_DATA;
  116. typedef struct LG_PIPE_DATA
  117. {
  118. BYTE nCommand;
  119. union
  120. {
  121. LG_PIPE_SEND_CMD_DATA sendcmd;
  122. LG_PIPE_SEND_EVT_DATA sendevt;
  123. LG_PIPE_RECEIVE_CMD_DATA receivecmd;
  124. LG_PIPE_RECEIVE_EVT_DATA receiveevt;
  125. };
  126. }LG_PIPE_DATA, *PLG_PIPE_DATA;
  127. #pragma pack()
  128. };
  129. */
  130. #endif