/* 
*	file: triggerSerialPort.h
*	author: Eric J Martin
*	
*	copyright: MBARI 2013
*
*	Defines a class object for interacting with a windows
*	serial port used for sending a pulse on it TX line. 
*
*/

#pragma once
#ifndef TRIGGERSERIALPORT_H_
#define TRIGGERSERIALPORT_H_

#include <stdio.h>
#include <tchar.h>
#include <Windows.h>


class triggerSerialPort
{
public:
	triggerSerialPort(TCHAR * sNewDevice);	// Constructor
	~triggerSerialPort(void);				// Destructor
	bool sendTrigger(void);					// Send a ascii 0X00 character on the serial port
	bool setRTS(int);						// Set the RTS line status (0=LOW / 1=HIGH)
	bool isConnected(void);					// return true if the serial port is open
	bool closeSerialPort(void);				// release the serial port
	bool changePortSettings(DWORD baudRate, BYTE byteSize, TCHAR parity, BYTE stopBits); // post-initialization changes
private:
	bool initializeSerialPort(void);		// set default configuration on the open port
	bool openSerialPort(void);				// open the port
	
	DCB dcbSerialParams;

	HANDLE hSerial;
	TCHAR sDevice[255];
	bool bIsConnected;
	
};

#endif //TRIGGERSERIALPORT_H_

