RS232Device.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 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 #ifndef CRS232DEVICE_H
00019 #define CRS232DEVICE_H
00020 
00021 // ---- local includes ------------------------------------------------------ ;
00022 
00023 #include "../Device/ProtocolDevice.h"
00024 #include "../Util/StopWatch.h"
00025 
00026 // ---- global includes ----------------------------------------------------- ;
00027 
00028 #ifdef __LINUX__
00029         #include <fcntl.h>
00030         #include <termios.h>    
00031 #endif
00032 #ifdef __QNX__
00033         #include <sys/types.h>
00034         #include <sys/stat.h>
00035         #include <sys/select.h>
00036         #include <fcntl.h>
00037         #include <termios.h>    
00038 #endif
00039 
00040 class CRS232Device : public CProtocolDevice  
00041 {
00042         private:
00043 
00044                 // ---- private data ---------------------------------------------------- ;
00045         
00046                 // ---- private auxiliary functions ------------------------------------- ;
00047 
00048         protected:
00049 
00050                 // ---- protected data -------------------------------------------------- ;
00051 
00052 #if defined (_WIN32)
00053                         HANDLE m_hDevice;
00054 #endif
00055 #if defined(__LINUX__)
00056                         int m_hDevice;
00057 #endif
00058 #if defined (__QNX__)
00059                         int m_hDevice;
00060 #endif
00061                         int m_iDeviceId;
00062                         unsigned long  m_uiBaudRate;    
00063                         unsigned long m_uiTimeOut;
00064                         CStopWatch m_clTimer;
00065 
00066                 // ---- protected auxiliary functions ----------------------------------- ;
00067 
00068                         int getDeviceError(int iErrorState);
00069                         int setBaudRate();
00070                         int setMessageId(unsigned long uiMessageId);
00071                         int clearReadQueue();
00072                         int reinit(unsigned char ucBaudRateId);
00073                         int readDevice(CProtocolMessage& rclProtocolMessage);
00074                         int writeDevice(CProtocolMessage& rclProtocolMessage);
00075 
00076         public:
00077 
00078                 // ---- public data ----------------------------------------------------- ;
00079 
00080 
00081         
00082                 // ---- constructors / destructor --------------------------------------- ;
00083 
00085                         CRS232Device();
00087                         CRS232Device(const CRS232Device& rclRS232Device);
00089                         virtual ~CRS232Device();
00090 
00091                 // ---- operators ------------------------------------------------------- ;
00092                 
00093                         // assignment operator
00094                         CRS232Device& operator=(const CRS232Device& rclRS232Device);
00095 
00096                 // ---- query functions ------------------------------------------------- ;
00097 
00098                 // ---- modify functions ------------------------------------------------ ;
00099                         
00100                         void setQueueSize(unsigned short uiQueueSize);
00101                         void setTimeOut(unsigned long uiTimeOut);
00102 
00103                 // ---- I/O functions --------------------------------------------------- ;
00104 
00105                 // ---- exec functions -------------------------------------------------- ;
00106 
00107                         int init();
00108                         int init(const char* acInitString);
00109                         int exit();
00110 };
00111 
00112 #endif


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:13