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.
|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: SocketRS232.h
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Header file of SocketRS232.h
//----------------------------------------------------------------------------
#ifndef __SOCKETRS232__H__INCLUDED__
#define __SOCKETRS232__H__INCLUDED__
#if _MSC_VER > 1000
#pragma once
#endif
#include "Socket.h"
class CSocketRS232 : public CSocket{
public: CSocketRS232(); virtual ~CSocketRS232();
protected: BOOL Create( LPCTSTR pPort, INT nBaudRate, INT nBitCount, INT nParity, INT nStopBit );
void Start() { ::SetEvent( m_hEventStart ); }
void Destroy();
protected: enum { CMD_STOP, CMD_COMMAND, CMD_WRITE, CMD_READ, CMD_WAIT, CMD_PAUSE };
virtual int OnCommand(); virtual void OnRecreate( int nError ); virtual void OnBeforeWrite( LPBYTE pBuffer, DWORD& nCount ); virtual int OnAfterWrite(); virtual void OnBeforeWait( DWORD& dwTime, DWORD& dwEvent ); virtual int OnAfterWait( DWORD dwEvent );
virtual void OnBeforeRead( DWORD& nCount, DWORD& dwTime ); virtual int OnAfterRead( LPBYTE pBuffer, DWORD nCount );
virtual int OnPause( DWORD &dwTime );
private: BOOL CreateCommPort(); DWORD ThreadProc(); friend static DWORD CALLBACK ThreadProcSocketRS232( LPVOID lpvParam ) { return ((CSocketRS232*)lpvParam)->ThreadProc(); }
private: enum { MAX_BUFFER_SIZE = 2048 }; HANDLE m_hThread; HANDLE m_hEventQuit; HANDLE m_hEventStart;
protected: HANDLE m_hCommPort;
private: struct PORT { TCHAR pPort[MAX_PATH]; INT nBaudRate; INT nBitCount; INT nParity; INT nStopBit; }m_Port;};
#endif
|