rs232-cygwin.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007 SCHUNK GmbH & Co. KG
00003  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *   http://www.apache.org/licenses/LICENSE-2.0
00010 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 //======================================================================
00045 //======================================================================
00046 
00047 #ifndef RS232_CYGWIN_H_
00048 #define RS232_CYGWIN_H_
00049 
00050 //----------------------------------------------------------------------
00051 // System Includes - include with <>
00052 //----------------------------------------------------------------------
00053 
00054 #include <string>
00055 #include <termios.h>
00056 
00057 //----------------------------------------------------------------------
00058 // Project Includes - include with ""
00059 //----------------------------------------------------------------------
00060 
00061 #include "sdhexception.h"
00062 #include "serialbase.h"
00063 #include "sdhlibrary_settings.h"
00064 
00065 //----------------------------------------------------------------------
00066 // Defines, enums, unions, structs,
00067 //----------------------------------------------------------------------
00068 
00069 NAMESPACE_SDH_START
00070 
00071 
00072 //----------------------------------------------------------------------
00073 // Global variables
00074 //----------------------------------------------------------------------
00075 
00076 
00077 //----------------------------------------------------------------------
00078 // Function and class member declarations
00079 //----------------------------------------------------------------------
00080 
00081 
00082 
00083 
00084 
00088 class cRS232Exception: public cSerialBaseException
00089 {
00090 public:
00091   cRS232Exception(cMsg const & _msg)
00092     : cSerialBaseException("cRS232Exception", _msg)
00093   {}
00094 };
00095 //======================================================================
00096 
00097 
00101 class cRS232 : public cSerialBase
00102 {
00103 
00104 protected:
00106   int port;
00107 
00109   std::string device_format_string;
00110 
00112   unsigned long baudrate;
00113 
00115   int fd;
00116 
00118   tcflag_t BaudrateToBaudrateCode(unsigned long baudrate)
00119   throw (cRS232Exception*);
00120 
00121   int status;
00122 
00123   termios io_set_old;
00124 
00125 public:
00136   cRS232(int _port, unsigned long _baudrate, double _timeout, char const* _device_format_string = "/dev/ttyS%d");
00137 
00150   void Open(void)
00151   throw (cRS232Exception*);
00152 
00154   bool IsOpen(void)
00155   throw();
00156 
00158   void Close(void)
00159   throw (cRS232Exception*);
00160 
00162 
00170   int write(char const *ptr, int len = 0)
00171   throw (cRS232Exception*);
00172 
00181   ssize_t Read(void *data, ssize_t size, long timeout_us, bool return_on_less_data)
00182   throw (cRS232Exception*);
00183 
00185   virtual bool UseCRC16()
00186   {
00187     return true;
00188   }
00189 
00190 };
00191 //======================================================================
00192 
00193 NAMESPACE_SDH_END
00194 
00195 #endif
00196 
00197 
00198 //======================================================================
00199 /*
00200   Here are some settings for the emacs/xemacs editor (and can be safely ignored):
00201   (e.g. to explicitely set C++ mode for *.h header files)
00202 
00203   Local Variables:
00204   mode:C++
00205   mode:ELSE
00206   End:
00207 */
00208 //======================================================================


schunk_sdh
Author(s): Mathias Luedtke , Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:21