Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | Examples

AsyncSerial.h

Go to the documentation of this file.
00001 
00035 #ifndef SERIAL_INCLUDED
00036 #define SERIAL_INCLUDED
00037 
00038 
00039 /****************************************************************************
00040  *
00041  * System Includes
00042  *
00043  ****************************************************************************/
00044 
00045 #include <sigc++/signal_system.h>
00046 #include <termios.h>
00047 #include <unistd.h>
00048 
00049 #include <string>
00050 
00051 
00052 /****************************************************************************
00053  *
00054  * Project Includes
00055  *
00056  ****************************************************************************/
00057 
00058 
00059 
00060 /****************************************************************************
00061  *
00062  * Local Includes
00063  *
00064  ****************************************************************************/
00065 
00066 
00067 
00068 /****************************************************************************
00069  *
00070  * Forward declarations
00071  *
00072  ****************************************************************************/
00073 
00074 
00075 
00076 /****************************************************************************
00077  *
00078  * Namespace
00079  *
00080  ****************************************************************************/
00081 
00082 namespace Async
00083 {
00084 
00085 
00086 /****************************************************************************
00087  *
00088  * Forward declarations of classes inside of the declared namespace
00089  *
00090  ****************************************************************************/
00091 
00092 class FdWatch;
00093 class SerialDevice;
00094   
00095 
00096 /****************************************************************************
00097  *
00098  * Defines & typedefs
00099  *
00100  ****************************************************************************/
00101 
00102 
00103 
00104 /****************************************************************************
00105  *
00106  * Exported Global Variables
00107  *
00108  ****************************************************************************/
00109 
00110 
00111 
00112 /****************************************************************************
00113  *
00114  * Class definitions
00115  *
00116  ****************************************************************************/
00117 
00129 class Serial : public SigC::Object
00130 {
00131   public:
00135     typedef enum
00136     {
00137       PARITY_NONE,  
00138       PARITY_EVEN,  
00139       PARITY_ODD    
00140     } Parity;
00141 
00145     typedef enum
00146     {
00147       FLOW_NONE,    
00148       FLOW_HW,      
00149       FLOW_XONOFF   
00150     } Flow;
00151     
00155     typedef enum
00156     {
00157       PIN_NONE, 
00158       PIN_RTS,  
00159       PIN_DTR,  
00160       PIN_CTS,  
00161       PIN_DSR,  
00162       PIN_DCD,  
00163       PIN_RI    
00164     } Pin;
00165     
00169     static const int READ_BUFSIZE = 1024;
00170         
00171 
00176     Serial(const std::string& serial_port);
00177   
00181     ~Serial(void);
00182     
00199     bool setParams(int speed, Parity parity, int bits, int stop_bits,
00200                    Flow flow);
00201     
00212     bool open(void);
00213     
00223     bool close(void);
00224     
00233     int write(const char *buf, size_t count)
00234     {
00235       return ::write(fd, buf, count);
00236     }
00237 
00254     bool setCanonical(bool canonical);
00255     
00266     bool stopInput(bool stop);
00267 
00279     bool setPin(Pin pin, bool set);
00280     
00292     bool getPin(Pin pin, bool &is_set);
00293 
00304     SigC::Signal2<void, char*, int> charactersReceived;
00305     
00306       
00307   protected:
00308     
00309   private:    
00310     const std::string   serial_port;
00311     bool                canonical;
00312     
00313     int                 fd;
00314     struct termios      port_settings;
00315     SerialDevice        *dev;
00316     
00317 
00318 };  /* class Serial */
00319 
00320 
00321 } /* namespace */
00322 
00323 #endif /* SERIAL_INCLUDED */
00324 
00325 
00326 
00327 /*
00328  * This file has not been truncated
00329  */
00330 

Generated on Sat Dec 3 00:20:38 2005 for Async by  doxygen 1.4.4