//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 08/10/2003 // PROJECT: Laserguard libraries // SUBSYSTEM: Communication support library // FILE: RS232.h // AUTHOR: Chizhevskiy Sergey // OVERVIEW // ~~~~~~~~ // Header file of CConnectionRS232 //---------------------------------------------------------------------------- #ifndef __CONNECTION__RS232__H__INCLUDED__ #define __CONNECTION__RS232__H__INCLUDED__ #if _MSC_VER > 1000 #pragma once #endif #include "Connect.h" class CConnectionRS232 : public CConnection { public: CConnectionRS232(); virtual ~CConnectionRS232(); public: BOOL Create( LPCTSTR pPort, INT nBaudRate, INT nBitCount, INT nParity, INT nStopBit, DWORD dwReadBufferSize, DWORD dwWriteBufferSize ); void Destroy(); public: HANDLE GetCommPortHandle() { return m_hCommPort; } HANDLE GetOperationStopEvent() { return m_hEventQuit; } public: BOOL EscapeFunction( DWORD dwFunc ) { return ::EscapeCommFunction( m_hCommPort, dwFunc ); } BOOL SetCommState( LPDCB pDCB ); BOOL GetCommState( LPDCB pDCB ); public: BOOL ClearCommError( LPDWORD lpErrors, LPCOMSTAT lpStat ); public: BOOL Flush(); virtual DWORD Read( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout ); virtual DWORD Write( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout ); virtual BOOL SetRTS( BOOL bOn ); virtual BOOL SetDTR( BOOL bOn ); protected: DWORD CommRead( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout ); DWORD CommWrite( PBYTE pBuffer, DWORD dwSize, DWORD dwTimeout ); private: HANDLE m_hCommPort; DWORD m_dwCommMask; OVERLAPPED m_ovWrite; OVERLAPPED m_ovWriteWait; OVERLAPPED m_ovRead; OVERLAPPED m_ovReadWait; HANDLE m_hEventQuit; struct tagCreateParams { TCHAR pPort[MAX_PATH]; INT nBaudRate; INT nBitCount; INT nParity; INT nStopBit; DWORD dwReadBufferSize; DWORD dwWriteBufferSize; }m_CreateParams; private: BOOL Create(); }; #endif