/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: src/drivers/wintel32/core/comms/wintel32comport.cpp

*/

#include "drivers/wintel32/device.hpp"
#include "drivers/wintel32/core/core.hpp"


CDriverWintel32CommPortDevice::CDriverWintel32CommPortDevice(HANDLE fileHandle) {
	m_hPort = fileHandle;
}

tUINT32 CDriverWintel32CommPortDevice::read(tBYTE *pBuffer, tUINT32 bufferSize) {
	if(m_hPort == INVALID_HANDLE_VALUE) {
		return 0;
	}

	DWORD readBytes;
	ReadFile(m_hPort, pBuffer, bufferSize, &readBytes, NULL);
	return (tUINT32)readBytes;
}


tUINT32 CDriverWintel32CommPortDevice::write(const tBYTE *pBuffer, tUINT32 bufferSize) {
	return 0;
}

tBOOL CDriverWintel32CommPortDevice::close() {
	CloseHandle(m_hPort);
	m_hPort = INVALID_HANDLE_VALUE;
	return TRUE;
}
