KatanaNativeInterface $VERSION$
|
00001 /* 00002 * Katana Native Interface - A C++ interface to the robot arm Katana. 00003 * Copyright (C) 2005 Neuronics AG 00004 * Check out the AUTHORS file for detailed contact information. 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 00021 00022 00023 #ifndef _CDLCOM_H_ 00024 #define _CDLCOM_H_ 00025 00026 #include "common/dllexport.h" 00027 00028 #include "KNI/cdlBase.h" 00029 #include "KNI/cdlCOMExceptions.h" 00030 00031 #include <string> 00032 00033 00034 //-------------------------------------------------------// 00035 #ifdef WIN32 00036 //-------------------------------------------------------// 00037 #include <windows.h> 00038 //-------------------------------------------------------// 00039 #else //LINUX 00040 //-------------------------------------------------------// 00041 #include <termios.h> 00042 #include <fcntl.h> 00043 #include <cerrno> 00044 //-------------------------------------------------------// 00045 #endif //WIN32 else LINUX 00046 //-------------------------------------------------------// 00047 00048 00053 struct TCdlCOMDesc { 00054 int port; 00055 int baud; 00056 int data; 00057 int parity; 00058 int stop; 00059 int rttc; 00060 int wttc; 00061 }; 00062 00063 //--------------------------------------------------------------------------// 00064 00065 00073 class DLLDIR CCdlCOM : public CCdlBase { 00074 private: 00075 std::string _deviceName; 00076 00077 protected: 00078 00079 TCdlCOMDesc _ccd; 00080 00081 //-------------------------------------------------------// 00082 #ifdef WIN32 00083 //-------------------------------------------------------// 00084 HANDLE _prtHdl; 00085 COMMTIMEOUTS _oto; 00086 //-------------------------------------------------------// 00087 #else //LINUX 00088 //-------------------------------------------------------// 00089 int _prtHdl; 00090 struct termios _oto; 00091 //-------------------------------------------------------// 00092 #endif //WIN32 else LINUX 00093 //-------------------------------------------------------// 00094 00095 protected: 00096 00099 static char digit(const int _val) { 00100 return (char)((int)'0' + _val); 00101 } 00102 00103 public: 00110 CCdlCOM(TCdlCOMDesc ccd, const char *dev_name = 0); 00111 virtual ~CCdlCOM(); 00114 virtual int send(const void* buf, int size); 00117 virtual int recv(void* buf, int size); 00120 }; 00121 00122 00123 #endif //_CDLCOM_H_ 00124