/*********************************************************************
 * This file is part of the cpplibs suite.
 *
 * Copyright (C) 2001 Topi Mäenpää
 * All rights reserved.
 *
 * This program is free software. You can redistribute and/or modify
 * it under the terms of the free software licence found in the
 * accompanying file "COPYING". The licence terms must always be
 * redistributed with this source file. The above copyright notice
 * must be reproduced in all modified and unmodified copies of this
 * source file.
 *
 * $Revision: 1.5 $
 *********************************************************************/

#ifndef _RS232_H
#define _RS232_H

#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>

#include "IO.h"
#include "GeneralFile.h"

namespace util { namespace io {
	/**
	 * A class for accessing the RS232 serial port. The port settings
	 * will be temporarily fixed at 9600, 8N1, XON/XOFF.
	 **/
	class RS232 : public GeneralFile
	{
	public:
#ifdef linux
		RS232(const char* device = "/dev/ttyS0", int type = O_RDWR);
#else
		RS232(const char* device = "/dev/ttyb", int type = O_RDWR);
#endif
		virtual ~RS232();
		
		void open(void) throw (IOException&);

		const char* getDeviceName(void) { return device; }

	private:
		char* device;
		int type;
	};

}}

#endif
