Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArSerialConnection.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
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   // Internal open, for use by open and openSimple
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   // these both return -1 for errors
00111   int rateToBaud(int rate);
00112   int baudToRate(int baud);
00113   // this just tries
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

Generated on Wed Oct 19 12:56:36 2005 for Aria by  doxygen 1.4.0