rs232-vcc.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008 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 //======================================================================
00044 //======================================================================
00045 
00046 #ifndef RS232_VCC_h
00047 #define RS232_VCC_h
00048 
00049 #include "sdhlibrary_settings.h"
00050 
00051 #if SDH_USE_VCC
00052 # pragma warning(disable : 4996)
00053 # pragma warning(disable : 4290)
00054 # pragma once
00055 #endif
00056 
00057 //----------------------------------------------------------------------
00058 // System Includes - include with <>
00059 //----------------------------------------------------------------------
00060 
00061 #include <windows.h>
00062 
00063 //----------------------------------------------------------------------
00064 // Project Includes - include with ""
00065 //----------------------------------------------------------------------
00066 
00067 #include "sdhexception.h"
00068 #include "serialbase.h"
00069 #include "sdhlibrary_settings.h"
00070 
00071 
00072 //#define RS_232_TEST
00073 #define SDH_RS232_VCC_ASYNC 0
00074 
00075 NAMESPACE_SDH_START
00076 
00077 class VCC_EXPORT cRS232Exception: public cSerialBaseException
00078 {
00079 public:
00080   cRS232Exception(cMsg const & _msg)
00081     : cSerialBaseException("cRS232Exception", _msg)
00082   {}
00083 };
00084 
00088 class VCC_EXPORT cRS232 : public cSerialBase
00089 {
00090 private:
00091 #ifndef RS_232_TEST
00092   HANDLE       _hCOM;
00093 #endif
00094 #if SDH_RS232_VCC_ASYNC
00095   OVERLAPPED   o;
00096 #endif
00097   COMMTIMEOUTS comm_timeouts;
00098   long         read_timeout_us; // for caching the read timeout in ms
00099 
00100 protected:
00102   int port;
00103 
00105   unsigned long baudrate;
00106 
00107 
00108 public:
00117   cRS232(int _port, unsigned long _baudrate, double _timeout, char const* _device_format_string = "");
00118   ~cRS232(void);
00119 
00120   void Open(void)
00121   throw (cRS232Exception*);
00122   void Close(void)
00123   throw (cRS232Exception*);
00124 
00125   virtual void SetTimeout(double _timeout)
00126   throw (cSerialBaseException*);
00127 
00128 #ifndef RS_232_TEST
00129   bool IsOpen()
00130   throw()
00131   {
00132     return _hCOM != NULL;
00133   }
00134 #else
00135   bool IsOpen()
00136   {
00137     return true;
00138   }
00139 #endif
00140   int write(char const *ptr, int len = 0)
00141   throw (cRS232Exception*);
00142 
00151   ssize_t Read(void *data, ssize_t size, long timeout_us, bool return_on_less_data)
00152   throw (cRS232Exception*);
00153 
00154   char* readline(char* line, int size, char* eol, bool return_on_less_data)
00155   throw (cRS232Exception*);
00156 
00158   virtual bool UseCRC16()
00159   {
00160     return true;
00161   }
00162 };
00163 
00164 NAMESPACE_SDH_END
00165 
00166 #endif


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