00001 /*************************************************************************** 00002 LOW_portSerialLinux.h - description 00003 ------------------- 00004 begin : Mon Jul 29 2002 00005 copyright : (C) 2002 by Harald Roelle, Helmut Reiser 00006 email : roelle@informatik.uni-muenchen.de, reiser@informatik.uni-muenchen.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef LOW_PORTSERIAL_LINUX_H 00019 #define LOW_PORTSERIAL_LINUX_H 00020 00021 00022 #include <string> 00023 00024 #include "LOW_portSerial.h" 00025 00026 00027 00028 /** Platform specific portSerial for Linux platforms. 00029 00030 @todo Add OS-level locking of serial port (e.g. uucp style). 00031 00032 @author Harald Roelle, Helmut Reiser 00033 */ 00034 class LOW_portSerial_Linux : public LOW_portSerial { 00035 00036 //======================================================================================= 00037 public: 00038 00039 //===================================================================================== 00040 // 00041 // constructors 00042 // 00043 00044 /** Constructor. 00045 00046 @param inPortSpec Path to serial port device file. 00047 */ 00048 LOW_portSerial_Linux( const string inSerialPort); 00049 00050 /** Destructor. 00051 */ 00052 virtual ~LOW_portSerial_Linux(); 00053 00054 00055 //======================================================================================= 00056 protected: 00057 00058 //===================================================================================== 00059 // 00060 // methods 00061 // 00062 00063 void tty_configure( const flowControl_t inFlowCtl, const dataBitsSite_t inDataBits, 00064 const parity_t inParity, const stopBits_t inStopBits, const speed_t inSpeed) const; 00065 00066 void tty_flush( const bool inFlushIn = true, const bool inFlushOut = true) const; 00067 00068 void tty_break() const; 00069 00070 uint8_t tty_readByte( const bool inTrashExtraReply = false) const; 00071 00072 void tty_read( byteVec_t &outReadBytes, const bool inTrashExtraReply = false) const; 00073 00074 void tty_write( const uint8_t inWriteByte) const; 00075 00076 void tty_write( const byteVec_t &inWriteBytes) const; 00077 00078 00079 00080 //======================================================================================= 00081 private: 00082 00083 //===================================================================================== 00084 // 00085 // constants 00086 // 00087 00088 /** Timeout of serial operations in seconds */ 00089 static const int serialTimeout = 5; 00090 00091 00092 //===================================================================================== 00093 // 00094 // attributes 00095 // 00096 00097 const string serialPortPath; /**< Path to device file */ 00098 int serialFD; /**< File descriptor of serial port. */ 00099 }; 00100 00101 #endif