00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #ifndef ARSERIALCONNECTION_H
00028 #define ARSERIALCONNECTION_H
00029 
00030 #include <string>
00031 #include "ariaTypedefs.h"
00032 #include "ArDeviceConnection.h"
00033 
00034 #ifndef WIN32
00035 #define TIOGETTIMESTAMP         0x5480
00036 #define TIOSTARTTIMESTAMP       0x5481
00037 #endif
00038 
00040 class ArSerialConnection: public ArDeviceConnection
00041 {
00042  public:
00044   ArSerialConnection();
00046   virtual ~ArSerialConnection();
00047 
00051   int open(const char * port = NULL);
00052 
00056   void setPort(const char *port = NULL);
00057 
00061   const char * getPort(void);
00062   
00063   virtual bool openSimple(void);  
00064   virtual int getStatus(void);
00065   virtual bool close(void);
00066   virtual int read(const char *data, unsigned int size, 
00067                             unsigned int msWait = 0);
00068   virtual int write(const char *data, unsigned int size);
00069   virtual const char * getOpenMessage(int messageNumber);
00070 
00072   bool setBaud(int baud);
00074   int getBaud(void);
00075 
00077   bool setHardwareControl(bool hardwareControl);
00079   bool getHardwareControl(void);
00080 
00082   bool getCTS(void);
00083 
00085   bool getDSR(void);
00086 
00088   bool getDCD(void);
00089 
00091   bool getRing(void);
00092 
00093   
00094   int internalOpen(void);
00095 
00096   enum Open { 
00097       OPEN_COULD_NOT_OPEN_PORT = 1, 
00098       OPEN_COULD_NOT_SET_UP_PORT, 
00099       OPEN_INVALID_BAUD_RATE, 
00100       OPEN_COULD_NOT_SET_BAUD, 
00101       OPEN_ALREADY_OPEN 
00102   };
00103   virtual ArTime getTimeRead(int index);
00104   virtual bool isTimeStamping(void);
00105 
00106  protected:
00107   void buildStrMap(void);
00108 
00109 #ifndef WIN32
00110   
00111   int rateToBaud(int rate);
00112   int baudToRate(int baud);
00113   
00114   void startTimeStamping(void);
00115   bool myTakingTimeStamps;
00116 #endif
00117     
00118   ArStrMap myStrMap;
00119   std::string myPortName;
00120   int myBaudRate;
00121   int myStatus;
00122   bool myHardwareControl;
00123 
00124 #ifndef WIN32
00125   int myPort;
00126 #endif // ifdef linux
00127 
00128 #ifdef WIN32
00129   HANDLE myPort;
00130 #endif // ifdef WIN32
00131 
00132 
00133 };
00134 
00135 #endif