#ifndef _WINCOMM_H_
#define _WINCOMM_H_

#include <iostream>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#include <wtypes.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "commdef.h"
#include "interface.h"


class ARCLIB_API WinCommInterface : public ArcInterface
{
	friend class CArclib;
public:		
	WinCommInterface();	
	~WinCommInterface();
	bool init(const char nPortNum, char nBaudRate = 7, char nStopBit = 0);
	int send(sIF_CMD_BLOCK *ifData);	
	int recv(sIF_CMD_BLOCK *ifData);		
	int syncSend(sIF_CMD_BLOCK *ifData);
	int	getMTU();
	void *getDeviceHandle();
	void requirelock();
	void releaselock();

private:
	BOOL ClearReadBuffer();
	BOOL ClearWriteBuffer();
	BOOL ClearReadWriteBuffer();
	HANDLE	m_hComm;
	HANDLE	m_hSyncComm;
	PSECURITY_DESCRIPTOR	pSD;
};

#endif