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.

80 lines
1.9 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:
  7. // SUBSYSTEM:
  8. // FILE: SocketRS232.h
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of SocketRS232.h
  13. //----------------------------------------------------------------------------
  14. #ifndef __SOCKETRS232__H__INCLUDED__
  15. #define __SOCKETRS232__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #include "Socket.h"
  20. class CSocketRS232 : public CSocket
  21. {
  22. public:
  23. CSocketRS232();
  24. virtual ~CSocketRS232();
  25. protected:
  26. BOOL Create( LPCTSTR pPort, INT nBaudRate, INT nBitCount, INT nParity, INT nStopBit );
  27. void Start() { ::SetEvent( m_hEventStart ); }
  28. void Destroy();
  29. protected:
  30. enum { CMD_STOP, CMD_COMMAND, CMD_WRITE, CMD_READ, CMD_WAIT, CMD_PAUSE };
  31. virtual int OnCommand();
  32. virtual void OnRecreate( int nError );
  33. virtual void OnBeforeWrite( LPBYTE pBuffer, DWORD& nCount );
  34. virtual int OnAfterWrite();
  35. virtual void OnBeforeWait( DWORD& dwTime, DWORD& dwEvent );
  36. virtual int OnAfterWait( DWORD dwEvent );
  37. virtual void OnBeforeRead( DWORD& nCount, DWORD& dwTime );
  38. virtual int OnAfterRead( LPBYTE pBuffer, DWORD nCount );
  39. virtual int OnPause( DWORD &dwTime );
  40. private:
  41. BOOL CreateCommPort();
  42. DWORD ThreadProc();
  43. friend static DWORD CALLBACK ThreadProcSocketRS232( LPVOID lpvParam )
  44. { return ((CSocketRS232*)lpvParam)->ThreadProc(); }
  45. private:
  46. enum { MAX_BUFFER_SIZE = 2048 };
  47. HANDLE m_hThread;
  48. HANDLE m_hEventQuit;
  49. HANDLE m_hEventStart;
  50. protected:
  51. HANDLE m_hCommPort;
  52. private:
  53. struct PORT
  54. {
  55. TCHAR pPort[MAX_PATH];
  56. INT nBaudRate;
  57. INT nBitCount;
  58. INT nParity;
  59. INT nStopBit;
  60. }m_Port;
  61. };
  62. #endif