Blob Blame Raw
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b68dd9a..ff109b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,7 @@
 cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+
 project(HokuyoAIST)
 string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
 include(${PROJECT_SOURCE_DIR}/cmake/hokuyoaist_utils.cmake)
diff --git a/doc/content/index.txt b/doc/content/index.txt
index a398d49..84a2720 100644
--- a/doc/content/index.txt
+++ b/doc/content/index.txt
@@ -29,7 +29,7 @@ separately.
 Flexiport is available from GitHub_.
 
 .. _github:
-   http://www.gibhub.com/gbiggs/flexiport
+   http://www.github.com/gbiggs/flexiport
 
 
 Examples
diff --git a/include/hokuyoaist/hokuyo_errors.h b/include/hokuyoaist/hokuyo_errors.h
index a007361..5615ab3 100644
--- a/include/hokuyoaist/hokuyo_errors.h
+++ b/include/hokuyoaist/hokuyo_errors.h
@@ -72,7 +72,7 @@ class HOKUYOAIST_EXPORT BaseError : public std::exception
         */
         BaseError(unsigned int desc_code, char const* error_type);
         BaseError(BaseError const& rhs);
-        virtual ~BaseError() throw() {};
+        virtual ~BaseError() throw() {}
 
         virtual unsigned int desc_code() const throw()
             { return desc_code_; }
@@ -80,18 +80,15 @@ class HOKUYOAIST_EXPORT BaseError : public std::exception
         virtual char const* error_type() const throw()
             { return error_type_; }
 
-#if __cplusplus >= 201103L
         virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
 
     protected:
         /** Description code for use with the error string table. */
         unsigned int desc_code_;
 
         /** Formatted description of the error. */
-        std::stringstream ss;
+        std::string error_str_;
+
         /** String representation of the error. */
         char error_type_[32];
 }; //class BaseError
@@ -127,7 +124,7 @@ class HOKUYOAIST_EXPORT RuntimeError : public BaseError
         RuntimeError(unsigned int desc_code, char const* error_type)
             : BaseError(desc_code, error_type)
         {}
-        virtual ~RuntimeError() throw() {};
+        virtual ~RuntimeError() throw() {}
 }; // class RuntimeError
 
 
@@ -164,22 +161,12 @@ class HOKUYOAIST_EXPORT BaudrateError: public RuntimeError
         /** @brief Baud rate error constructor.
 
         @param baud The bad baud rate. */
-        BaudrateError(unsigned int baud)
-            : RuntimeError(6, "BaudrateError"), baud_(baud)
-        {}
-        BaudrateError(BaudrateError const& rhs)
-            : RuntimeError(rhs), baud_(rhs.baud())
-        {}
+        BaudrateError(unsigned int baud);
+        BaudrateError(BaudrateError const& rhs);
 
         unsigned int baud() const throw()
             { return baud_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Baud rate that caused the error. */
         unsigned int baud_;
@@ -361,14 +348,8 @@ class HOKUYOAIST_EXPORT ChecksumError: public ProtocolError
 
         @param expected The expected checksum.
         @param calculated The calculated checksum. */
-        ChecksumError(int expected, int calculated)
-            : ProtocolError(24, "ChecksumError"), expected_(expected),
-            calculated_(calculated)
-        {}
-        ChecksumError(ChecksumError const& rhs)
-            : ProtocolError(rhs), expected_(rhs.expected()),
-            calculated_(rhs.calculated())
-        {}
+        ChecksumError(int expected, int calculated);
+        ChecksumError(ChecksumError const& rhs);
 
         virtual int expected() const throw()
             { return expected_; }
@@ -376,12 +357,6 @@ class HOKUYOAIST_EXPORT ChecksumError: public ProtocolError
         virtual int calculated() const throw()
             { return calculated_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Expected checksum value. */
         int expected_;
@@ -423,12 +398,6 @@ class HOKUYOAIST_EXPORT UnknownLineError: public ProtocolError
         virtual char const* const line() const throw()
             { return line_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** The mystery line. */
         char line_[128];
@@ -452,12 +421,6 @@ class HOKUYOAIST_EXPORT ParseError: public ProtocolError
         virtual char const* const type() const throw()
             { return type_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** The bad line. */
         char line_[128];
@@ -484,20 +447,8 @@ class HOKUYOAIST_EXPORT ResponseError: public ProtocolError
 
         @param error The two-byte error code received.
         @param cmd The command that caused the error. */
-        ResponseError(char const* const error, char const* const cmd)
-            : ProtocolError(30, "ResponseError")
-        {
-            error_[0] = error[0]; error_[1] = error[1];
-            cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
-        }
-        ResponseError(ResponseError const& rhs)
-            : ProtocolError(rhs)
-        {
-            error_[0] = rhs.error_code()[0];
-            error_[1] = rhs.error_code()[1];
-            cmd_[0] = rhs.cmd_code()[0];
-            cmd_[1] = rhs.cmd_code()[1];
-        }
+        ResponseError(char const* const error, char const* const cmd);
+        ResponseError(ResponseError const& rhs);
 
         /// Get the two-byte error code as a non-null-terminated array.
         virtual char const* const error_code() const throw()
@@ -507,12 +458,6 @@ class HOKUYOAIST_EXPORT ResponseError: public ProtocolError
         virtual char const* const cmd_code() const throw()
             { return cmd_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Error code as defined in SCIP2 (two bytes). */
         char error_[2];
@@ -529,15 +474,8 @@ class HOKUYOAIST_EXPORT Scip1ResponseError: public ProtocolError
 
         @param error The two-byte error code received.
         @param cmd The command that caused the error. */
-        Scip1ResponseError(char error, char cmd)
-            : ProtocolError(30, "Scip1ResponseError"),
-            error_(error), cmd_(cmd)
-        {}
-        Scip1ResponseError(Scip1ResponseError const& rhs)
-            : ProtocolError(rhs), error_(rhs.error_code()),
-            cmd_(rhs.cmd_code())
-        {}
-
+        Scip1ResponseError(char error, char cmd);
+        Scip1ResponseError(Scip1ResponseError const& rhs);
         /// Get the one-byte error code.
         virtual char error_code() const throw()
             { return error_; }
@@ -546,12 +484,6 @@ class HOKUYOAIST_EXPORT Scip1ResponseError: public ProtocolError
         virtual char cmd_code() const throw()
             { return cmd_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Error code as defined in SCIP2 (two bytes). */
         char error_;
@@ -568,20 +500,8 @@ class HOKUYOAIST_EXPORT CommandEchoError: public ProtocolError
 
         @param cmd The two-byte command code expected.
         @param echo The two-byte command echo received. */
-        CommandEchoError(char const* const cmd, char const* const echo)
-            : ProtocolError(31, "CommandEchoError")
-        {
-            cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
-            echo_[0] = echo[0]; echo_[1] = echo[1];
-        }
-        CommandEchoError(CommandEchoError const& rhs)
-            : ProtocolError(rhs)
-        {
-            cmd_[0] = rhs.cmd_code()[0];
-            cmd_[1] = rhs.cmd_code()[1];
-            echo_[0] = rhs.cmd_echo()[0];
-            echo_[1] = rhs.cmd_echo()[1];
-        }
+        CommandEchoError(char const* const cmd, char const* const echo);
+        CommandEchoError(CommandEchoError const& rhs);
 
         /// Get the two-byte command code as a non-null-terminated array.
         virtual char const* const cmd_code() const throw()
@@ -591,12 +511,6 @@ class HOKUYOAIST_EXPORT CommandEchoError: public ProtocolError
         virtual char const* const cmd_echo() const throw()
             { return echo_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Command that triggered the error, from SCIP2 (two bytes). */
         char cmd_[2];
@@ -612,28 +526,13 @@ class HOKUYOAIST_EXPORT ParamEchoError: public ProtocolError
         /** @brief Parameter echo error constructor.
 
         @param cmd The two-byte command code sent. */
-        ParamEchoError(char const* const cmd)
-            : ProtocolError(32, "ParamEchoError")
-        {
-            cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
-        }
-        ParamEchoError(ParamEchoError const& rhs)
-            : ProtocolError(rhs)
-        {
-            cmd_[0] = rhs.cmd_code()[0];
-            cmd_[1] = rhs.cmd_code()[1];
-        }
+        ParamEchoError(char const* const cmd);
+        ParamEchoError(ParamEchoError const& rhs);
 
         /// Get the two-byte command code as a non-null-terminated array.
         virtual char const* const cmd_code() const throw()
             { return cmd_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Command that triggered the error, from SCIP2 (two bytes). */
         char cmd_[2];
@@ -648,14 +547,8 @@ class HOKUYOAIST_EXPORT InsufficientBytesError: public ProtocolError
 
         @param num The number of bytes received.
         @param line_length The length of the line. */
-        InsufficientBytesError(int num, int line_length)
-            : ProtocolError(33, "InsufficientBytesError"),
-            num_(num), line_length_(line_length)
-        {}
-        InsufficientBytesError(InsufficientBytesError const& rhs)
-            : ProtocolError(rhs), num_(rhs.num()),
-            line_length_(rhs.line_length())
-        {}
+        InsufficientBytesError(int num, int line_length);
+        InsufficientBytesError(InsufficientBytesError const& rhs);
 
         virtual int num() const throw()
             { return num_; }
@@ -663,12 +556,6 @@ class HOKUYOAIST_EXPORT InsufficientBytesError: public ProtocolError
         virtual int line_length() const throw()
             { return line_length_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** Number of bytes available. */
         int num_;
@@ -685,14 +572,8 @@ class HOKUYOAIST_EXPORT LineLengthError: public ProtocolError
 
         @param length The number of bytes received.
         @param expected The expected length of the line. */
-        LineLengthError(int length, int expected)
-            : ProtocolError(34, "LineLengthError"),
-            length_(length), expected_(expected)
-        {}
-        LineLengthError(LineLengthError const& rhs)
-            : ProtocolError(rhs), length_(rhs.length()),
-            expected_(rhs.expected())
-        {}
+        LineLengthError(int length, int expected);
+        LineLengthError(LineLengthError const& rhs);
 
         virtual int length() const throw()
             { return length_; }
@@ -700,12 +581,6 @@ class HOKUYOAIST_EXPORT LineLengthError: public ProtocolError
         virtual int expected() const throw()
             { return expected_; }
 
-#if __cplusplus >= 201103L
-        virtual const char* what() const throw();
-#else
-        virtual const char* what() throw();
-#endif
-
     protected:
         /** The received line length. */
         int length_;
@@ -713,7 +588,7 @@ class HOKUYOAIST_EXPORT LineLengthError: public ProtocolError
         int expected_;
 }; // class LineLengthError
 
-}; // namespace hokuyoaist
+} // namespace hokuyoaist
 
 /** @} */
 
diff --git a/python/hokuyo_aist.cpp b/python/hokuyo_aist.cpp
index 3922980..4201d45 100644
--- a/python/hokuyo_aist.cpp
+++ b/python/hokuyo_aist.cpp
@@ -43,8 +43,7 @@ class BaseErrorWrap
         {
             return BaseError::error_type();
         }
-
-        const char* what() throw()
+        const char* what() const throw()
         {
             if (boost::python::override f = get_override("what"))
             {
@@ -52,7 +51,7 @@ class BaseErrorWrap
             }
             return BaseError::what();
         }
-        const char* default_what() throw()
+        const char* default_what() const throw()
         {
             return BaseError::what();
         }
diff --git a/src/hokuyo_errors.cpp b/src/hokuyo_errors.cpp
index dd76a8d..884e624 100644
--- a/src/hokuyo_errors.cpp
+++ b/src/hokuyo_errors.cpp
@@ -367,56 +367,46 @@ BaseError::BaseError(unsigned int desc_code, char const* error_type)
     : desc_code_(desc_code)
 {
     strncpy(error_type_, error_type, 32);
+    std::stringstream ss;
+    ss << error_type_ << " (" << desc_code_ << "): " <<
+        desc_code_to_string(desc_code_);
+    error_str_ = ss.str();
 }
 
 
 BaseError::BaseError(BaseError const& rhs)
-    : desc_code_(rhs.desc_code())
+    : desc_code_(rhs.desc_code()),
+    error_str_(rhs.error_str_)
 {
     strncpy(error_type_, rhs.error_type(), 32);
 }
 
-
-#if __cplusplus >= 201103L
 const char* BaseError::what() const throw()
-#else
-const char* BaseError::what() throw()
-#endif
 {
-    ss << error_type_ << " (" << desc_code_ << "): " <<
-        desc_code_to_string(desc_code_);
-    return ss.str().c_str();
+    return error_str_.c_str();
 }
 
-
-#if __cplusplus >= 201103L
-const char* BaudrateError::what() const throw()
-#else
-const char* BaudrateError::what() throw()
-#endif
+BaudrateError::BaudrateError(unsigned int baud)
+    : RuntimeError(6, "BaudrateError"), baud_(baud)
 {
-    RuntimeError::what();
+    std::stringstream ss;
     ss << baud_;
-    return ss.str().c_str();
+    error_str_ += ss.str();
 }
 
-
-#if __cplusplus >= 201103L
-const char* ChecksumError::what() const throw()
-#else
-const char* ChecksumError::what() throw()
-#endif
+ChecksumError::ChecksumError(int expected, int calculated)
+    : ProtocolError(24, "ChecksumError"), expected_(expected), calculated_(calculated)
 {
-    ProtocolError::what();
+    std::stringstream ss;
     ss << "expected " << expected_ << ", calculated " << calculated_;
-    return ss.str().c_str();
+    error_str_ += ss.str();
 }
 
-
 UnknownLineError::UnknownLineError(char const* const line)
     : ProtocolError(27, "UnknownLineError")
 {
     strncpy(line_, line, 128);
+    error_str_ += std::string(line);
 }
 
 
@@ -426,24 +416,14 @@ UnknownLineError::UnknownLineError(UnknownLineError const& rhs)
     strncpy(line_, rhs.line(), 128);
 }
 
-
-#if __cplusplus >= 201103L
-const char* UnknownLineError::what() const throw()
-#else
-const char* UnknownLineError::what() throw()
-#endif
-{
-    ProtocolError::what();
-    ss << line_;
-    return ss.str().c_str();
-}
-
-
 ParseError::ParseError(char const* const line, char const* const type)
     : ProtocolError(28, "ParseError")
 {
     strncpy(line_, line, 128);
     strncpy(type_, type, 16);
+    std::stringstream ss;
+    ss << "Line type: " << type_ << ". Line: " << line_;
+    error_str_ += ss.str();
 }
 
 
@@ -454,95 +434,107 @@ ParseError::ParseError(ParseError const& rhs)
     strncpy(type_, rhs.type(), 16);
 }
 
-
-#if __cplusplus >= 201103L
-const char* ParseError::what() const throw()
-#else
-const char* ParseError::what() throw()
-#endif
+ResponseError::ResponseError(char const* const error, char const* const cmd)
+    : ProtocolError(30, "ResponseError")
 {
-    ProtocolError::what();
-    ss << "Line type: " << type_ << ". Line: " << line_;
-    return ss.str().c_str();
-}
-
-
-#if __cplusplus >= 201103L
-const char* ResponseError::what() const throw()
-#else
-const char* ResponseError::what() throw()
-#endif
-{
-    ProtocolError::what();
+    error_[0] = error[0]; error_[1] = error[1];
+    cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
+    std::stringstream ss;
     ss << " Command: " << cmd_[0] << cmd_[1];
     ss << " Error : (" << error_[0] << error_[1] << ") " <<
         scip2_error_to_string(error_, cmd_);
-    return ss.str().c_str();
+    error_str_ += ss.str();
+}
+ResponseError::ResponseError(ResponseError const& rhs)
+    : ProtocolError(rhs)
+{
+    error_[0] = rhs.error_code()[0];
+    error_[1] = rhs.error_code()[1];
+    cmd_[0] = rhs.cmd_code()[0];
+    cmd_[1] = rhs.cmd_code()[1];
 }
 
-
-#if __cplusplus >= 201103L
-const char* Scip1ResponseError::what() const throw()
-#else
-const char* Scip1ResponseError::what() throw()
-#endif
+Scip1ResponseError::Scip1ResponseError(char error, char cmd)
+    : ProtocolError(30, "Scip1ResponseError"),
+    error_(error), cmd_(cmd)
 {
-    ProtocolError::what();
+    std::stringstream ss;
     ss << " Command: " << cmd_;
     ss << " Error : " << error_;
-    return ss.str().c_str();
+    error_str_ += ss.str();
+}
+Scip1ResponseError::Scip1ResponseError(Scip1ResponseError const& rhs)
+    : ProtocolError(rhs), error_(rhs.error_code()),
+    cmd_(rhs.cmd_code())
+{
 }
 
-
-#if __cplusplus >= 201103L
-const char* CommandEchoError::what() const throw()
-#else
-const char* CommandEchoError::what() throw()
-#endif
+CommandEchoError::CommandEchoError(char const* const cmd, char const* const echo)
+    : ProtocolError(31, "CommandEchoError")
 {
-    ProtocolError::what();
+    cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
+    echo_[0] = echo[0]; echo_[1] = echo[1];
+    std::stringstream ss;
     ss << " Command: " << cmd_[0] << cmd_[1];
     ss << " Received echo: " << echo_[0] << echo_[1];
-    return ss.str().c_str();
-}
+    error_str_ += ss.str();
 
+}
+CommandEchoError::CommandEchoError(CommandEchoError const& rhs)
+    : ProtocolError(rhs)
+{
+    cmd_[0] = rhs.cmd_code()[0];
+    cmd_[1] = rhs.cmd_code()[1];
+    echo_[0] = rhs.cmd_echo()[0];
+    echo_[1] = rhs.cmd_echo()[1];
+}
 
-#if __cplusplus >= 201103L
-const char* ParamEchoError::what() const throw()
-#else
-const char* ParamEchoError::what() throw()
-#endif
+ParamEchoError::ParamEchoError(char const* const cmd)
+    : ProtocolError(32, "ParamEchoError")
 {
-    ProtocolError::what();
+    cmd_[0] = cmd[0]; cmd_[1] = cmd[1];
+    std::stringstream ss;
     ss << " Command: " << cmd_[0] << cmd_[1];
-    return ss.str().c_str();
+    error_str_ += ss.str();
 }
 
+ParamEchoError::ParamEchoError(ParamEchoError const& rhs)
+    : ProtocolError(rhs)
+{
+    cmd_[0] = rhs.cmd_code()[0];
+    cmd_[1] = rhs.cmd_code()[1];
+}
 
-#if __cplusplus >= 201103L
-const char* InsufficientBytesError::what() const throw()
-#else
-const char* InsufficientBytesError::what() throw()
-#endif
+InsufficientBytesError::InsufficientBytesError(int num, int line_length)
+    : ProtocolError(33, "InsufficientBytesError"),
+    num_(num), line_length_(line_length)
 {
-    ProtocolError::what();
+    std::stringstream ss;
     ss << " Number of bytes: " << num_;
     ss << " Line length: " << line_length_;
-    return ss.str().c_str();
+    error_str_ += ss.str();
+}
+InsufficientBytesError::InsufficientBytesError(InsufficientBytesError const& rhs)
+    : ProtocolError(rhs), num_(rhs.num()),
+    line_length_(rhs.line_length())
+{
 }
 
-
-#if __cplusplus >= 201103L
-const char* LineLengthError::what() const throw()
-#else
-const char* LineLengthError::what() throw()
-#endif
+LineLengthError::LineLengthError(int length, int expected)
+    : ProtocolError(34, "LineLengthError"),
+    length_(length), expected_(expected)
 {
-    ProtocolError::what();
+    std::stringstream ss;
     ss << " Received length: " << length_;
     ss << " Expected line length: " << expected_;
-    return ss.str().c_str();
+    error_str_ += ss.str();
+}
+
+LineLengthError::LineLengthError(LineLengthError const& rhs)
+    : ProtocolError(rhs), length_(rhs.length()),
+    expected_(rhs.expected())
+{
 }
 
-}; // namespace hokuyoaist
+} // namespace hokuyoaist
 
diff --git a/src/sensor.cpp b/src/sensor.cpp
index fa2a042..6e207d8 100644
--- a/src/sensor.cpp
+++ b/src/sensor.cpp
@@ -1772,7 +1772,7 @@ void Sensor::find_model(char const* buffer)
     {
         model_ = MODEL_UHG08LX;
     }
-    else if(strstr(buffer, "UTM-30LX") != 0)
+    else if(strstr(buffer, "UTM-30LX") != 0 || strstr(buffer, "UTM-X002S") != 0)
     {
         model_ = MODEL_UTM30LX;
         // Also enable the work around for a checksum problem in this