/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Class: cSerial // Created by: Kristian Mueller// Created on: Sat Jun 18 16:59:36 2005 // Inspired and copyed from // Lars Hildebrandt (Copyright (C) 2001) #ifndef _CSERIAL_H_ #define _CSERIAL_H_ #include <termios.h> #include "cFile.h" class cSerial : public cFile{ public: cSerial(); virtual ~cSerial(); // to open a com-port (overload the OpenFile method to save terminal settings) // in Linux: "/dev/ttyS0" -> Com1 "/dev/ttyS1" -> Com2 bool openFile(const char* device, const int mode = O_RDWR|O_NOCTTY); // closes the com-port (overload the CloseFile method to restore the terminal settings void closeFile(void); // sets the com-speed bool setupBaudRate(const unsigned int speed); // sets the timeout for the port in 100 ms bool setupTimeOuts(const unsigned int timeout = 0, const unsigned int min = 0); bool sendACK(); bool waitForACK(); protected: // to configure the port void configurePort(const struct termios& tios); private: struct termios aOriginalTermSettings; }; #endif //_CSERIAL_H_