socketcan-bcm: Fix wrongly opened socket
[apps/agl-service-can-low-level.git] / low-can-binding / diagnostic / active-diagnostic-request.cpp
index 71f5980..80d2e69 100644 (file)
@@ -15,8 +15,9 @@
  * limitations under the License.
  */
 
-#include <map>
+
 #include <fnmatch.h>
+#include <map>
 
 #include "active-diagnostic-request.hpp"
 
 
 std::string active_diagnostic_request_t::prefix_ = "diagnostic_messages";
 
-bool active_diagnostic_request_t::operator==(const active_diagnostic_request_t& b)
-{
-       return (bus_ == b.bus_ && id_ == b.id_ && handle_ == b.handle_);
-}
-
-active_diagnostic_request_t& active_diagnostic_request_t::operator=(const active_diagnostic_request_t& adr)
-{
-       if (this != &adr)
-       {
-               bus_ = adr.bus_;
-               id_ = adr.id_;
-               handle_ = adr.handle_;
-               name_ = adr.name_;
-               decoder_ = adr.decoder_;
-               callback_ = adr.callback_;
-               recurring_ = adr.recurring_;
-               wait_for_multiple_responses_ = adr.wait_for_multiple_responses_;
-               frequency_clock_ = adr.frequency_clock_;
-               timeout_clock_ = adr.timeout_clock_;
-               socket_ = adr.socket_;
-       }
-
-       return *this;
-}
-
-active_diagnostic_request_t::active_diagnostic_request_t()
-       : bus_{nullptr},
-         id_{0},
-         handle_{nullptr},
-         name_{""},
-         decoder_{nullptr},
-         callback_{nullptr},
-         recurring_{false},
-         wait_for_multiple_responses_{false},
-         frequency_clock_{frequency_clock_t()},
-         timeout_clock_{frequency_clock_t()},
-         socket_{}
-{}
-
 active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus, uint32_t id,
                const std::string& name,
                bool wait_for_multiple_responses,
                const DiagnosticResponseDecoder decoder,
                const DiagnosticResponseCallback callback,
-               float frequencyHz)
+               float frequencyHz,
+               bool permanent)
        : bus_{bus},
          id_{id},
          handle_{nullptr},
@@ -78,6 +41,7 @@ active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus,
          decoder_{decoder},
          callback_{callback},
          recurring_{frequencyHz ? true : false},
+         permanent_{permanent},
          wait_for_multiple_responses_{wait_for_multiple_responses},
          frequency_clock_{frequency_clock_t(frequencyHz)},
          timeout_clock_{frequency_clock_t(10)},
@@ -133,6 +97,11 @@ bool active_diagnostic_request_t::get_recurring() const
        return recurring_;
 }
 
+bool active_diagnostic_request_t::get_permanent() const
+{
+       return permanent_;
+}
+
 frequency_clock_t& active_diagnostic_request_t::get_frequency_clock()
 {
        return frequency_clock_;
@@ -153,22 +122,6 @@ void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticR
        handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr));
 }
 
-///
-/// @brief Check if requested signal name is a diagnostic message. If the name
-///  begin with the diagnostic message prefix then true else false.
-///
-/// @param[in] name - A signal name.
-///
-/// @return true if name began with the diagnostic message prefix else false.
-///
-bool active_diagnostic_request_t::is_diagnostic_signal(const std::string& name)
-{
-       const std::string p = active_diagnostic_request_t::prefix_ + "*";
-       if(::fnmatch(p.c_str(), name.c_str(), FNM_CASEFOLD) == 0)
-               return true;
-       return false;
-}
-
 /// @brief Returns true if a sufficient response has been received for a
 /// diagnostic request.
 ///