API
modbus_exception.hpp
Go to the documentation of this file.
1 // header only version of modbuspp
2 //
3 //
4 // Created by Fanzhe on 5/29/2017.
5 //
6 // MagAO-X:
7 // Cloned from https://github.com/fanzhe98/modbuspp
8 // On commit 73cabdc, Date: Sat Nov 24 23:16:51 2018 -0500
9 //
10 // License: GPLv3
11 //
12 // Header only version created by Jared Males
13 // -- removed "using namespace std".
14 //
15 //
16 //
17 //
18 
19 #ifndef MODBUSPP_MODBUS_EXCEPTION_H
20 #define MODBUSPP_MODBUS_EXCEPTION_H
21 
22 #include <exception>
23 
24 
25 /// Modbus Exception Class
26 /**
27  * Modbus Exeception Super Class
28  *
29  * Throwed when a exception or errors happens in modbus protocol
30  */
31 class modbus_exception : public std::exception {
32 public:
33  std::string msg;
34  virtual const char* what() const throw()
35  {
36  return "A Error In Modbus Happened!";
37  }
38 };
39 
40 
41 /// Modbus Connect Exception
42 /**
43  * Connection Issue
44  *
45  * Throwed when a connection issues happens between modbus client and server
46  */
48 public:
49  virtual const char* what() const throw()
50  {
51  return "Having Modbus Connection Problem";
52  }
53 };
54 
55 
56 /// Modbus Illgal Function Exception
57 /**
58  * Illegal Function
59  *
60  * Throwed when modbus server return error response function 0x01
61  */
63 public:
64  virtual const char* what() const throw()
65  {
66  return "Illegal Function";
67  }
68 };
69 
70 
71 /// Modbus Illegal Address Exception
72 /**
73  * Illegal Address
74  *
75  * Throwed when modbus server return error response function 0x02
76  */
78 public:
79 
81  {
82  msg = "test";
83  }
84 
85  const char* what() const throw()
86  {
87  return "Illegal Address";
88  }
89 };
90 
91 
92 /// Modbus Illegal Data Value Exception
93 /**
94  * Illegal Data Vlaue
95  *
96  * Throwed when modbus server return error response function 0x03
97  */
99 public:
100  virtual const char* what() const throw()
101  {
102  return "Illegal Data Value";
103  }
104 };
105 
106 
107 /// Modbus Server Failure Exception
108 /**
109  * Server Failure
110  *
111  * Throwed when modbus server return error response function 0x04
112  */
114 public:
115  virtual const char* what() const throw()
116  {
117  return "Server Failure";
118  }
119 };
120 
121 
122 /// Modbus Acknowledge Exception
123 /**
124  * Acknowledge
125  *
126  * Throwed when modbus server return error response function 0x05
127  */
129 public:
130  virtual const char* what() const throw()
131  {
132  return "Acknowledge";
133  }
134 };
135 
136 
137 /// Modbus Server Busy Exception
138 /**
139  * Server Busy
140  *
141  * Throwed when modbus server return error response function 0x06
142  */
144 public:
145  virtual const char* what() const throw()
146  {
147  return "Server Busy";
148  }
149 };
150 
151 /// Modbus Gate Way Problem Exception
152 /**
153  * Gate Way Problem
154  *
155  * Throwed when modbus server return error response function 0x0A and 0x0B
156  */
158 public:
159  virtual const char* what() const throw()
160  {
161  return "Gateway Problem";
162  }
163 };
164 
165 /// Modbus Buffer Exception
166 /**
167  * Buffer Exception
168  *
169  * Throwed when buffer is too small for the data to be storaged.
170  */
172 public:
173  virtual const char* what() const throw()
174  {
175  return "Size of Buffer Is too Small!";
176  }
177 };
178 
179 
180 /// Modbus Amount Exception
181 /**
182  * Amount Exception
183  *
184  * Throwed when the address or amount input is mismatching.
185  */
187 public:
188  virtual const char* what() const throw()
189  {
190  return "Too many Data!";
191  }
192 };
193 
194 
195 
196 #endif //MODBUSPP_MODBUS_EXCEPTION_H
Modbus Acknowledge Exception.
virtual const char * what() const
Modbus Amount Exception.
virtual const char * what() const
Modbus Buffer Exception.
virtual const char * what() const
Modbus Connect Exception.
virtual const char * what() const
Modbus Exception Class.
virtual const char * what() const
Modbus Gate Way Problem Exception.
virtual const char * what() const
Modbus Illegal Address Exception.
Modbus Illegal Data Value Exception.
virtual const char * what() const
Modbus Illgal Function Exception.
virtual const char * what() const
Modbus Server Busy Exception.
virtual const char * what() const
Modbus Server Failure Exception.
virtual const char * what() const