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.

83 lines
2.1 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: RS232.h
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of CConnectionRS232
  13. //----------------------------------------------------------------------------
  14. #ifndef __CONNECTION__RS232__H__INCLUDED__
  15. #define __CONNECTION__RS232__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #include "Connect.h"
  20. class CConnectionRS232 :
  21. public CConnection
  22. {
  23. public:
  24. CConnectionRS232();
  25. virtual ~CConnectionRS232();
  26. public:
  27. BOOL Create( LPCTSTR pPort, INT nBaudRate, INT nBitCount, INT nParity, INT nStopBit, DWORD dwReadBufferSize, DWORD dwWriteBufferSize );
  28. void Destroy();
  29. public:
  30. HANDLE GetCommPortHandle() { return m_hCommPort; }
  31. HANDLE GetOperationStopEvent() { return m_hEventQuit; }
  32. public:
  33. BOOL EscapeFunction( DWORD dwFunc ) { return ::EscapeCommFunction( m_hCommPort, dwFunc ); }
  34. BOOL SetCommState( LPDCB pDCB );
  35. BOOL GetCommState( LPDCB pDCB );
  36. public:
  37. BOOL ClearCommError( LPDWORD lpErrors, LPCOMSTAT lpStat );
  38. public:
  39. BOOL Flush();
  40. virtual DWORD Read( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout );
  41. virtual DWORD Write( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout );
  42. virtual BOOL SetRTS( BOOL bOn );
  43. virtual BOOL SetDTR( BOOL bOn );
  44. protected:
  45. DWORD CommRead( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout );
  46. DWORD CommWrite( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout );
  47. private:
  48. HANDLE m_hCommPort;
  49. DWORD m_dwCommMask;
  50. OVERLAPPED m_ovWrite;
  51. OVERLAPPED m_ovWriteWait;
  52. OVERLAPPED m_ovRead;
  53. OVERLAPPED m_ovReadWait;
  54. HANDLE m_hEventQuit;
  55. struct tagCreateParams
  56. {
  57. TCHAR pPort[MAX_PATH];
  58. INT nBaudRate;
  59. INT nBitCount;
  60. INT nParity;
  61. INT nStopBit;
  62. DWORD dwReadBufferSize;
  63. DWORD dwWriteBufferSize;
  64. }m_CreateParams;
  65. private:
  66. BOOL Create();
  67. };
  68. #endif