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

ArSerialConnection.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
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 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARSERIALCONNECTION_H
00027 #define ARSERIALCONNECTION_H
00028 
00029 #include <string>
00030 #include "ariaTypedefs.h"
00031 #include "ArDeviceConnection.h"
00032 
00033 #ifndef WIN32
00034 #define TIOGETTIMESTAMP         0x5480
00035 #define TIOSTARTTIMESTAMP       0x5481
00036 #endif
00037 
00039 class ArSerialConnection: public ArDeviceConnection
00040 {
00041  public:
00043   AREXPORT ArSerialConnection();
00045   AREXPORT virtual ~ArSerialConnection();
00046 
00050   AREXPORT int open(const char * port = NULL);
00051 
00055   AREXPORT void setPort(const char *port = NULL);
00056 
00060   AREXPORT const char * getPort(void);
00061   
00062   AREXPORT virtual bool openSimple(void);  
00063   AREXPORT virtual int getStatus(void);
00064   AREXPORT virtual bool close(void);
00065   AREXPORT virtual int read(const char *data, unsigned int size, 
00066                 unsigned int msWait = 0);
00067   AREXPORT virtual int write(const char *data, unsigned int size);
00068   AREXPORT virtual const char * getOpenMessage(int messageNumber);
00069 
00071   AREXPORT bool setBaud(int baud);
00073   AREXPORT int getBaud(void);
00074 
00076   AREXPORT bool setHardwareControl(bool hardwareControl);
00078   AREXPORT bool getHardwareControl(void);
00079 
00081   AREXPORT bool getCTS(void);
00082 
00084   AREXPORT bool getDSR(void);
00085 
00087   AREXPORT bool getDCD(void);
00088 
00090   AREXPORT bool getRing(void);
00091 
00092   // Internal open, for use by open and openSimple
00093   AREXPORT int internalOpen(void);
00094 
00095   enum Open { 
00096       OPEN_COULD_NOT_OPEN_PORT = 1, 
00097       OPEN_COULD_NOT_SET_UP_PORT, 
00098       OPEN_INVALID_BAUD_RATE, 
00099       OPEN_COULD_NOT_SET_BAUD, 
00100       OPEN_ALREADY_OPEN 
00101   };
00102   AREXPORT virtual ArTime getTimeRead(int index);
00103   AREXPORT virtual bool isTimeStamping(void);
00104 
00105  protected:
00106   void buildStrMap(void);
00107 
00108 #ifndef WIN32
00109   // these both return -1 for errors
00110   int rateToBaud(int rate);
00111   int baudToRate(int baud);
00112   // this just tries
00113   void startTimeStamping(void);
00114   bool myTakingTimeStamps;
00115 #endif
00116     
00117   ArStrMap myStrMap;
00118   std::string myPortName;
00119   int myBaudRate;
00120   int myStatus;
00121   bool myHardwareControl;
00122 
00123 #ifndef WIN32
00124   int myPort;
00125 #endif // ifdef linux
00126 
00127 #ifdef WIN32
00128   HANDLE myPort;
00129 #endif // ifdef WIN32
00130 
00131 
00132 };
00133 
00134 #endif

Generated on Tue Feb 20 10:51:41 2007 for Aria by  doxygen 1.4.0