INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
hokuyo_errors.h
1/*
2 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3 * http://gearbox.sf.net/
4 * Copyright (c) 2008-2010 Geoffrey Biggs
5 *
6 * hokuyo_aist Hokuyo laser scanner driver.
7 *
8 * This distribution is licensed to you under the terms described in the
9 * LICENSE file included in this distribution.
10 *
11 * This work is a product of the National Institute of Advanced Industrial
12 * Science and Technology, Japan. Registration number: H22PRO-1086.
13 *
14 * This file is part of hokuyo_aist.
15 *
16 * This software is licensed under the Eclipse Public License -v 1.0 (EPL). See
17 * http://www.opensource.org/licenses/eclipse-1.0.txt
18 */
19
20#ifndef HOKUYO_ERRORS_H__
21#define HOKUYO_ERRORS_H__
22
23#include <sstream>
24
25#if defined(WIN32)
26 typedef unsigned char uint8_t;
27 typedef unsigned int uint32_t;
28 #if defined(HOKUYO_AIST_STATIC)
29 #define HOKUYO_AIST_EXPORT
30 #elif defined(HOKUYO_AIST_EXPORTS)
31 #define HOKUYO_AIST_EXPORT __declspec(dllexport)
32 #else
33 #define HOKUYO_AIST_EXPORT __declspec(dllimport)
34 #endif
35#else
36 #include <stdint.h>
37 #define HOKUYO_AIST_EXPORT
38#endif
39
43
44namespace hokuyo_aist
45{
46
48std::string scip2_error_to_string(char const* const error,
49 char const* const cmd);
50
52std::string desc_code_to_string(unsigned int code);
53
54
56class HOKUYO_AIST_EXPORT BaseError : public std::exception
57{
58 public:
62 BaseError(unsigned int desc_code, char const* error_type);
63 BaseError(BaseError const& rhs);
64 virtual ~BaseError() throw() {};
65
66 virtual unsigned int desc_code() const throw()
67 { return desc_code_; }
68
69 virtual char const* error_type() const throw()
70 { return error_type_; }
71
72 virtual const char* what() throw();
73
74 protected:
76 unsigned int desc_code_;
77
79 std::stringstream ss;
81 char error_type_[32];
82}; //class BaseError
83
84
86class HOKUYO_AIST_EXPORT LogicError : public BaseError
87{
88 public:
92 LogicError(unsigned int desc_code)
93 : BaseError(desc_code, "LogicError")
94 {}
95 LogicError(unsigned int desc_code, char const* error_type)
96 : BaseError(desc_code, error_type)
97 {}
98 virtual ~LogicError() throw() {};
99}; // class LogicError
100
101
103class HOKUYO_AIST_EXPORT RuntimeError : public BaseError
104{
105 public:
109 RuntimeError(unsigned int desc_code)
110 : BaseError(desc_code, "RuntimeError")
111 {}
112 RuntimeError(unsigned int desc_code, char const* error_type)
113 : BaseError(desc_code, error_type)
114 {}
115 virtual ~RuntimeError() throw() {};
116}; // class RuntimeError
117
118
120class HOKUYO_AIST_EXPORT ReadError: public RuntimeError
121{
122 public:
126 ReadError(unsigned int desc_code)
127 : RuntimeError(desc_code, "ReadError")
128 {}
129}; // class ReadError
130
131
133class HOKUYO_AIST_EXPORT WriteError: public RuntimeError
134{
135 public:
139 WriteError(unsigned int desc_code)
140 : RuntimeError(desc_code, "WriteError")
141 {}
142}; // class WriteError
143
144
146class HOKUYO_AIST_EXPORT BaudrateError: public RuntimeError
147{
148 public:
152 BaudrateError(unsigned int baud)
153 : RuntimeError(6, "BaudrateError"), baud_(baud)
154 {}
155 BaudrateError(BaudrateError const& rhs)
156 : RuntimeError(rhs), baud_(rhs.baud())
157 {}
158
159 unsigned int baud() const throw()
160 { return baud_; }
161
162 const char* what() throw();
163
164 protected:
166 unsigned int baud_;
167}; // class BaudrateError
168
169
171class HOKUYO_AIST_EXPORT CloseError: public RuntimeError
172{
173 public:
174 CloseError()
175 : RuntimeError(3, "CloseError")
176 {}
177}; // class CloseError
178
179
181class HOKUYO_AIST_EXPORT NoDestinationError: public RuntimeError
182{
183 public:
184 NoDestinationError()
185 : RuntimeError(11, "NoDestinationError")
186 {}
187}; // class NoDestinationError
188
189
191class HOKUYO_AIST_EXPORT FirmwareError: public RuntimeError
192{
193 public:
194 FirmwareError()
195 : RuntimeError(23, "FirmwareError")
196 {}
197}; // class FirmwareError
198
199
201class HOKUYO_AIST_EXPORT ScipVersionError: public RuntimeError
202{
203 public:
204 ScipVersionError()
205 : RuntimeError(22, "ScipVersionError")
206 {}
207}; // class ScipVersionError
208
209
211class HOKUYO_AIST_EXPORT UnknownScipVersionError: public RuntimeError
212{
213 public:
214 UnknownScipVersionError()
215 : RuntimeError(4, "UnknownScipVersionError")
216 {}
217}; // class UnknownScipVersionError
218
219
221class HOKUYO_AIST_EXPORT UnsupportedError: public RuntimeError
222{
223 public:
227 UnsupportedError(unsigned int desc_code)
228 : RuntimeError(desc_code, "UnsupportedError")
229 {}
230}; // class UnsupportedError
231
232
234class HOKUYO_AIST_EXPORT ArgError: public RuntimeError
235{
236 public:
240 ArgError(unsigned int desc_code)
241 : RuntimeError(desc_code, "ArgError")
242 {}
243 ArgError(unsigned int desc_code, char const* error_type)
244 : RuntimeError(desc_code, error_type)
245 {}
246 virtual ~ArgError() throw() {};
247}; // class ArgError
248
249
251class HOKUYO_AIST_EXPORT NoDataError: public RuntimeError
252{
253 public:
254 NoDataError()
255 : RuntimeError(13, "NoDataError")
256 {}
257}; // class NoDataError
258
259
261class HOKUYO_AIST_EXPORT NotSerialError: public RuntimeError
262{
263 public:
264 NotSerialError()
265 : RuntimeError(5, "NotSerialError")
266 {}
267}; // class NotSerialError
268
269
271class HOKUYO_AIST_EXPORT IndexError: public RuntimeError
272{
273 public:
274 IndexError()
275 : RuntimeError(2, "IndexError")
276 {}
277}; // class IndexError
278
279
281class HOKUYO_AIST_EXPORT SetIPError: public RuntimeError
282{
283 public:
284 SetIPError()
285 : RuntimeError(37, "SetIPError")
286 {}
287}; // class SetIPError
288
289
291class HOKUYO_AIST_EXPORT MotorSpeedError: public ArgError
292{
293 public:
294 MotorSpeedError()
295 : ArgError(9, "MotorSpeedError")
296 {}
297}; // class MotorSpeedError
298
299
301class HOKUYO_AIST_EXPORT StartStepError: public ArgError
302{
303 public:
304 StartStepError()
305 : ArgError(14, "StartStepError")
306 {}
307}; // class StartStepError
308
309
311class HOKUYO_AIST_EXPORT EndStepError: public ArgError
312{
313 public:
314 EndStepError()
315 : ArgError(15, "EndStepError")
316 {}
317}; // class EndStepError
318
319
321class HOKUYO_AIST_EXPORT ProtocolError: public RuntimeError
322{
323 public:
327 ProtocolError(unsigned int desc_code)
328 : RuntimeError(desc_code, "ProtocolError")
329 {}
330 ProtocolError(unsigned int desc_code, char const* error_type)
331 : RuntimeError(desc_code, error_type)
332 {}
333 virtual ~ProtocolError() throw() {}
334}; // class ProtocolError
335
336
338class HOKUYO_AIST_EXPORT ChecksumError: public ProtocolError
339{
340 public:
345 ChecksumError(int expected, int calculated)
346 : ProtocolError(24, "ChecksumError"), expected_(expected),
347 calculated_(calculated)
348 {}
349 ChecksumError(ChecksumError const& rhs)
350 : ProtocolError(rhs), expected_(rhs.expected()),
351 calculated_(rhs.calculated())
352 {}
353
354 virtual int expected() const throw()
355 { return expected_; }
356
357 virtual int calculated() const throw()
358 { return calculated_; }
359
360 const char* what() throw();
361
362 protected:
367}; // class ProtocolError
368
369
371class HOKUYO_AIST_EXPORT DataCountError: public ProtocolError
372{
373 public:
374 DataCountError()
375 : ProtocolError(25, "DataCountError")
376 {}
377}; // class DataCountError
378
379
381class HOKUYO_AIST_EXPORT MisplacedLineFeedError: public ProtocolError
382{
383 public:
384 MisplacedLineFeedError()
385 : ProtocolError(26, "MisplacedLineFeedError")
386 {}
387}; // class MisplacedLineFeedError
388
389
391class HOKUYO_AIST_EXPORT UnknownLineError: public ProtocolError
392{
393 public:
397 UnknownLineError(char const* const line);
399
400 virtual char const* const line() const throw()
401 { return line_; }
402
403 const char* what() throw();
404
405 protected:
407 char line_[128];
408}; // class UnknownLineError
409
410
412class HOKUYO_AIST_EXPORT ParseError: public ProtocolError
413{
414 public:
419 ParseError(char const* const line, char const* const type);
420 ParseError(ParseError const& rhs);
421
422 virtual char const* const line() const throw()
423 { return line_; }
424
425 virtual char const* const type() const throw()
426 { return type_; }
427
428 const char* what() throw();
429
430 protected:
432 char line_[128];
434 char type_[16];
435}; // class ParseError
436
437
439class HOKUYO_AIST_EXPORT MissingFirmSpecError: public ProtocolError
440{
441 public:
442 MissingFirmSpecError()
443 : ProtocolError(29, "MissingFirmSpecError")
444 {}
445}; // class MissingFirmSpecError
446
447
449class HOKUYO_AIST_EXPORT ResponseError: public ProtocolError
450{
451 public:
456 ResponseError(char const* const error, char const* const cmd)
457 : ProtocolError(30, "ResponseError")
458 {
459 error_[0] = error[0]; error_[1] = error[1];
460 cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
461 }
462 ResponseError(ResponseError const& rhs)
463 : ProtocolError(rhs)
464 {
465 error_[0] = rhs.error_code()[0];
466 error_[1] = rhs.error_code()[1];
467 cmd_[0] = rhs.cmd_code()[0];
468 cmd_[1] = rhs.cmd_code()[1];
469 }
470
472 virtual char const* const error_code() const throw()
473 { return error_; }
474
476 virtual char const* const cmd_code() const throw()
477 { return cmd_; }
478
479 const char* what() throw();
480
481 protected:
483 char error_[2];
485 char cmd_[2];
486}; // class ResponseError
487
488
490class HOKUYO_AIST_EXPORT Scip1ResponseError: public ProtocolError
491{
492 public:
497 Scip1ResponseError(char error, char cmd)
498 : ProtocolError(30, "Scip1ResponseError"),
499 error_(error), cmd_(cmd)
500 {}
502 : ProtocolError(rhs), error_(rhs.error_code()),
503 cmd_(rhs.cmd_code())
504 {}
505
507 virtual char error_code() const throw()
508 { return error_; }
509
511 virtual char cmd_code() const throw()
512 { return cmd_; }
513
514 const char* what() throw();
515
516 protected:
518 char error_;
520 char cmd_;
521}; // class Scip1ResponseError
522
523
525class HOKUYO_AIST_EXPORT CommandEchoError: public ProtocolError
526{
527 public:
532 CommandEchoError(char const* const cmd, char const* const echo)
533 : ProtocolError(31, "CommandEchoError")
534 {
535 cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
536 echo_[0] = echo[0]; echo_[1] = echo[1];
537 }
539 : ProtocolError(rhs)
540 {
541 cmd_[0] = rhs.cmd_code()[0];
542 cmd_[1] = rhs.cmd_code()[1];
543 echo_[0] = rhs.cmd_echo()[0];
544 echo_[1] = rhs.cmd_echo()[1];
545 }
546
548 virtual char const* const cmd_code() const throw()
549 { return cmd_; }
550
552 virtual char const* const cmd_echo() const throw()
553 { return echo_; }
554
555 const char* what() throw();
556
557 protected:
559 char cmd_[2];
561 char echo_[2];
562}; // class CommandEchoError
563
564
566class HOKUYO_AIST_EXPORT ParamEchoError: public ProtocolError
567{
568 public:
572 ParamEchoError(char const* const cmd)
573 : ProtocolError(32, "ParamEchoError")
574 {
575 cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
576 }
578 : ProtocolError(rhs)
579 {
580 cmd_[0] = rhs.cmd_code()[0];
581 cmd_[1] = rhs.cmd_code()[1];
582 }
583
585 virtual char const* const cmd_code() const throw()
586 { return cmd_; }
587
588 const char* what() throw();
589
590 protected:
592 char cmd_[2];
593}; // class ParamEchoError
594
595
597class HOKUYO_AIST_EXPORT InsufficientBytesError: public ProtocolError
598{
599 public:
604 InsufficientBytesError(int num, int line_length)
605 : ProtocolError(33, "InsufficientBytesError"),
606 num_(num), line_length_(line_length)
607 {}
609 : ProtocolError(rhs), num_(rhs.num()),
610 line_length_(rhs.line_length())
611 {}
612
613 virtual int num() const throw()
614 { return num_; }
615
616 virtual int line_length() const throw()
617 { return line_length_; }
618
619 const char* what() throw();
620
621 protected:
623 int num_;
626}; // class InsufficientBytesError
627
628
630class HOKUYO_AIST_EXPORT LineLengthError: public ProtocolError
631{
632 public:
637 LineLengthError(int length, int expected)
638 : ProtocolError(34, "LineLengthError"),
639 length_(length), expected_(expected)
640 {}
642 : ProtocolError(rhs), length_(rhs.length()),
643 expected_(rhs.expected())
644 {}
645
646 virtual int length() const throw()
647 { return length_; }
648
649 virtual int expected() const throw()
650 { return expected_; }
651
652 const char* what() throw();
653
654 protected:
659}; // class LineLengthError
660
661}; // namespace hokuyo_aist
662
664
665#endif // HOKUYO_ERRORS_H__
666
Bad argument error class.
Definition hokuyo_errors.h:235
ArgError(unsigned int desc_code)
Argument error constructor.
Definition hokuyo_errors.h:240
General error class.
Definition hokuyo_errors.h:57
std::stringstream ss
Definition hokuyo_errors.h:79
BaseError(unsigned int desc_code, char const *error_type)
Hokuyo error constructor.
Definition hokuyo_errors.cpp:327
unsigned int desc_code_
Definition hokuyo_errors.h:76
char error_type_[32]
Definition hokuyo_errors.h:81
Baudrate error class.
Definition hokuyo_errors.h:147
BaudrateError(unsigned int baud)
Baud rate error constructor.
Definition hokuyo_errors.h:152
unsigned int baud_
Definition hokuyo_errors.h:166
Bad checksum error.
Definition hokuyo_errors.h:339
int calculated_
Definition hokuyo_errors.h:366
int expected_
Definition hokuyo_errors.h:364
ChecksumError(int expected, int calculated)
Checksum error constructor.
Definition hokuyo_errors.h:345
Command echo error.
Definition hokuyo_errors.h:526
CommandEchoError(char const *const cmd, char const *const echo)
Command echo error constructor.
Definition hokuyo_errors.h:532
virtual char const *const cmd_echo() const
Get the two-byte command echo as a non-null-terminated array.
Definition hokuyo_errors.h:552
char echo_[2]
Definition hokuyo_errors.h:561
char cmd_[2]
Definition hokuyo_errors.h:559
virtual char const *const cmd_code() const
Get the two-byte command code as a non-null-terminated array.
Definition hokuyo_errors.h:548
Insufficient bytes to calculate checksum error.
Definition hokuyo_errors.h:598
int line_length_
Definition hokuyo_errors.h:625
InsufficientBytesError(int num, int line_length)
Insufficient bytes error constructor.
Definition hokuyo_errors.h:604
int num_
Definition hokuyo_errors.h:623
Incorrect line length error.
Definition hokuyo_errors.h:631
int expected_
Definition hokuyo_errors.h:658
LineLengthError(int length, int expected)
Line length error constructor.
Definition hokuyo_errors.h:637
int length_
Definition hokuyo_errors.h:656
Logic error class.
Definition hokuyo_errors.h:87
LogicError(unsigned int desc_code)
Logic error constructor.
Definition hokuyo_errors.h:92
Parameter echo error.
Definition hokuyo_errors.h:567
virtual char const *const cmd_code() const
Get the two-byte command code as a non-null-terminated array.
Definition hokuyo_errors.h:585
char cmd_[2]
Definition hokuyo_errors.h:592
ParamEchoError(char const *const cmd)
Parameter echo error constructor.
Definition hokuyo_errors.h:572
char type_[16]
Definition hokuyo_errors.h:434
ParseError(char const *const line, char const *const type)
Parse error constructor.
Definition hokuyo_errors.cpp:387
char line_[128]
Definition hokuyo_errors.h:432
Base protocol error.
Definition hokuyo_errors.h:322
ProtocolError(unsigned int desc_code)
Protocol error constructor.
Definition hokuyo_errors.h:327
ReadError(unsigned int desc_code)
Read error constructor.
Definition hokuyo_errors.h:126
Bad response error - may be sent in response to any command.
Definition hokuyo_errors.h:450
char cmd_[2]
Definition hokuyo_errors.h:485
ResponseError(char const *const error, char const *const cmd)
Response error constructor.
Definition hokuyo_errors.h:456
char error_[2]
Definition hokuyo_errors.h:483
virtual char const *const cmd_code() const
Get the two-byte command code as a non-null-terminated array.
Definition hokuyo_errors.h:476
virtual char const *const error_code() const
Get the two-byte error code as a non-null-terminated array.
Definition hokuyo_errors.h:472
Runtime error class.
Definition hokuyo_errors.h:104
RuntimeError(unsigned int desc_code)
Runtime error constructor.
Definition hokuyo_errors.h:109
Bad response error (SCIP1 version)
Definition hokuyo_errors.h:491
char error_
Definition hokuyo_errors.h:518
char cmd_
Definition hokuyo_errors.h:520
virtual char error_code() const
Get the one-byte error code.
Definition hokuyo_errors.h:507
virtual char cmd_code() const
Get the one-byte command code.
Definition hokuyo_errors.h:511
Scip1ResponseError(char error, char cmd)
Response error constructor.
Definition hokuyo_errors.h:497
char line_[128]
Definition hokuyo_errors.h:407
UnknownLineError(char const *const line)
Unknown line error constructor.
Definition hokuyo_errors.cpp:365
UnsupportedError(unsigned int desc_code)
Unsupported error constructor.
Definition hokuyo_errors.h:227
WriteError(unsigned int desc_code)
Write error constructor.
Definition hokuyo_errors.h:139
Hokuyo laser scanner driver name space.
std::string desc_code_to_string(unsigned int code)
Translates an error description code into a string.
Definition hokuyo_errors.cpp:279
std::string scip2_error_to_string(char const *const error, char const *const cmd)
Translates a SCIP2 error code into a string.
Definition hokuyo_errors.cpp:29
 

Generated for GearBox by  doxygen 1.4.5