00001 /*************************************************************************** 00002 LOW_portSerialLinux.h - description 00003 ------------------- 00004 begin : Mon Jul 29 2002 00005 copyright : (C) 2002 by Harald Roelle 00006 email : roelle@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 #include "LOW_portSerialFactory.h" 00026 #include "LOW_objectSynchronizer.h" 00027 00028 00029 00030 /** Platform specific portSerial for Linux platforms. 00031 00032 This class is thread-safe. 00033 00034 @todo Add OS-level locking of serial port (e.g. uucp style). 00035 00036 @author Harald Roelle 00037 */ 00038 class LOW_portSerial_Linux : public LOW_portSerial, LOW_objectSynchronizer { 00039 00040 //======================================================================================= 00041 public: 00042 00043 /** Destructor. 00044 */ 00045 virtual ~LOW_portSerial_Linux(); 00046 00047 00048 //===================================================================================== 00049 // 00050 // methods 00051 // 00052 00053 virtual void tty_configure( const flowControl_t inFlowCtl, const dataBitsSite_t inDataBits, 00054 const parity_t inParity, const stopBits_t inStopBits, const speed_t inSpeed); 00055 00056 virtual void tty_flush( const bool inFlushIn = true, const bool inFlushOut = true); 00057 00058 virtual void tty_break(); 00059 00060 virtual uint8_t tty_readByte( const bool inTrashExtraReply = false, const unsigned int inSecTimeout = defaultTimeout); 00061 00062 virtual void tty_read( byteVec_t &outReadBytes, const bool inTrashExtraReply = false, const unsigned int inSecTimeout = defaultTimeout); 00063 00064 virtual void tty_write( const uint8_t inWriteByte); 00065 00066 virtual void tty_write( const byteVec_t &inWriteBytes); 00067 00068 00069 00070 //======================================================================================= 00071 protected: 00072 00073 //===================================================================================== 00074 // 00075 // friend classes 00076 // 00077 00078 friend class LOW_portSerialFactory; /**< To allow construction. */ 00079 00080 00081 //===================================================================================== 00082 // 00083 // constructors 00084 // 00085 00086 /** Constructor. 00087 Not publicly constructable. Use LOW_portSerialFactory. 00088 00089 @param inPortSpec Path to serial port device file. 00090 */ 00091 LOW_portSerial_Linux( const LOW_portSerialFactory::portSpecifier_t inSerialPort); 00092 00093 00094 00095 //======================================================================================= 00096 private: 00097 00098 //===================================================================================== 00099 // 00100 // constants 00101 // 00102 00103 /** Timeout of serial operations in seconds */ 00104 //static const int serialTimeout = 5; 00105 00106 00107 //===================================================================================== 00108 // 00109 // attributes 00110 // 00111 00112 const std::string serialPortPath; /**< Path to device file */ 00113 int serialFD; /**< File descriptor of serial port. */ 00114 }; 00115 00116 #endif