RS232Device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
3  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef CRS232DEVICE_H
19 #define CRS232DEVICE_H
20 
21 // ---- local includes ------------------------------------------------------ ;
22 
23 #include "../Device/ProtocolDevice.h"
24 #include "../Util/StopWatch.h"
25 
26 // ---- global includes ----------------------------------------------------- ;
27 
28 #ifdef __LINUX__
29  #include <fcntl.h>
30  #include <termios.h>
31 #endif
32 #ifdef __QNX__
33  #include <sys/types.h>
34  #include <sys/stat.h>
35  #include <sys/select.h>
36  #include <fcntl.h>
37  #include <termios.h>
38 #endif
39 
41 {
42  private:
43 
44  // ---- private data ---------------------------------------------------- ;
45 
46  // ---- private auxiliary functions ------------------------------------- ;
47 
48  protected:
49 
50  // ---- protected data -------------------------------------------------- ;
51 
52 #if defined (_WIN32)
53  HANDLE m_hDevice;
54 #endif
55 #if defined(__LINUX__)
56  int m_hDevice;
57 #endif
58 #if defined (__QNX__)
59  int m_hDevice;
60 #endif
62  unsigned long m_uiBaudRate;
63  unsigned long m_uiTimeOut;
65 
66  // ---- protected auxiliary functions ----------------------------------- ;
67 
68  int getDeviceError(int iErrorState);
69  int setBaudRate();
70  int setMessageId(unsigned long uiMessageId);
71  int clearReadQueue();
72  int reinit(unsigned char ucBaudRateId);
73  int readDevice(CProtocolMessage& rclProtocolMessage);
74  int writeDevice(CProtocolMessage& rclProtocolMessage);
75 
76  public:
77 
78  // ---- public data ----------------------------------------------------- ;
79 
80 
81 
82  // ---- constructors / destructor --------------------------------------- ;
83 
85  CRS232Device();
87  CRS232Device(const CRS232Device& rclRS232Device);
89  virtual ~CRS232Device();
90 
91  // ---- operators ------------------------------------------------------- ;
92 
93  // assignment operator
94  CRS232Device& operator=(const CRS232Device& rclRS232Device);
95 
96  // ---- query functions ------------------------------------------------- ;
97 
98  // ---- modify functions ------------------------------------------------ ;
99 
100  void setQueueSize(unsigned short uiQueueSize);
101  void setTimeOut(unsigned long uiTimeOut);
102 
103  // ---- I/O functions --------------------------------------------------- ;
104 
105  // ---- exec functions -------------------------------------------------- ;
106 
107  int init();
108  int init(const char* acInitString);
109  int exit();
110 };
111 
112 #endif
int setBaudRate()
Definition: RS232Device.cpp:55
int writeDevice(CProtocolMessage &rclProtocolMessage)
unsigned long m_uiTimeOut
Definition: RS232Device.h:63
int readDevice(CProtocolMessage &rclProtocolMessage)
Definition: RS232Device.cpp:79
CStopWatch m_clTimer
Definition: RS232Device.h:64
int reinit(unsigned char ucBaudRateId)
Definition: RS232Device.cpp:73
CRS232Device()
default constructor
int getDeviceError(int iErrorState)
Definition: RS232Device.cpp:49
int setMessageId(unsigned long uiMessageId)
Definition: RS232Device.cpp:61
void setTimeOut(unsigned long uiTimeOut)
void setQueueSize(unsigned short uiQueueSize)
virtual ~CRS232Device()
destructor
int clearReadQueue()
Definition: RS232Device.cpp:67
CRS232Device & operator=(const CRS232Device &rclRS232Device)
unsigned long m_uiBaudRate
Definition: RS232Device.h:62


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:19