summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/diagnostic/active-diagnostic-request.cpp55
-rw-r--r--src/diagnostic/active-diagnostic-request.hpp13
-rw-r--r--src/diagnostic/diagnostic-manager.cpp10
-rw-r--r--src/diagnostic/diagnostic-manager.hpp1
4 files changed, 43 insertions, 36 deletions
diff --git a/src/diagnostic/active-diagnostic-request.cpp b/src/diagnostic/active-diagnostic-request.cpp
index 430e4f68..3e6ab140 100644
--- a/src/diagnostic/active-diagnostic-request.cpp
+++ b/src/diagnostic/active-diagnostic-request.cpp
@@ -17,41 +17,49 @@
#include "active-diagnostic-request.hpp"
-bool& operator==(const active_diagnostic_request_t& adr) const
+bool active_diagnostic_request_t::operator==(const active_diagnostic_request_t& b)
{
- return (bus_ == adr.bus_ && id_ == adr.id_ && handle_ == adr.handle_) ? true : false;
+ return (bus_ == b.bus_ && id_ == b.id_ && handle_ == b.handle_) ? true : false;
}
-active_diagnostic_request_t& operator=(const active_diagnostic_request_t& adr)
- : can_bus_dev_{adr.can_bus_dev_}, id_{adr.id_}, handle_{adr.handle_}, name_{adr.name_},
- decoder_{adr.decoder_}, callback_{adr.callback_}, reccuring_{adr.reccuring_}, wait_for_multiple_responses_{adr.wait_for_multiple_responses_},
- in_flight_{adr.in_flight_}, frequency_clock_{adr.frequency_clock_}, timeout_clock_{adr.timeout_clock_}
-{}
+active_diagnostic_request_t& active_diagnostic_request_t::operator=(const active_diagnostic_request_t& 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_;
+ in_flight_ = adr.in_flight_;
+ frequency_clock_ = adr.frequency_clock_;
+ timeout_clock_ = adr.timeout_clock_;
+
+ return *this;
+}
active_diagnostic_request_t::active_diagnostic_request_t()
- : can_bus_dev_{nullptr}, id_{0}, handle_{nullptr}, name_{""},
- decoder_{nullptr}, callback_{nullptr}, reccuring_{false}, wait_for_multiple_responses_{false},
+ : bus_{nullptr}, id_{0}, handle_{nullptr}, name_{""},
+ decoder_{nullptr}, callback_{nullptr}, recurring_{false}, wait_for_multiple_responses_{false},
in_flight_{false}, frequency_clock_{frequency_clock_t()}, timeout_clock_{frequency_clock_t()}
{}
-active_diagnostic_request_t(can_bus_dev_t* bus, DiagnosticRequest* request,
+active_diagnostic_request_t::active_diagnostic_request_t(can_bus_dev_t* bus, DiagnosticRequest* request,
const std::string& name, bool wait_for_multiple_responses,
const DiagnosticResponseDecoder decoder,
const DiagnosticResponseCallback callback, float frequencyHz)
: bus_{bus}, id_{request->arbitration_id}, handle_{nullptr}, name_{name},
- decoder_{decoder}, callback_{callback}, reccuring_{frequencyHz ? true : false}, wait_for_multiple_responses_{wait_for_multiple_responses},
+ decoder_{decoder}, callback_{callback}, recurring_{frequencyHz ? true : false}, wait_for_multiple_responses_{wait_for_multiple_responses},
in_flight_{false}, frequency_clock_{frequency_clock_t(frequencyHz)}, timeout_clock_{frequency_clock_t(10)}
-{
- entry->handle = generate_diagnostic_request(
- &manager->shims[bus->address - 1], request, NULL);
-}
+{}
can_bus_dev_t* active_diagnostic_request_t::get_can_bus_dev()
{
- return can_bus_dev_;
+ return bus_;
}
-DiagnosticRequestHandle& active_diagnostic_request_t::get_handle()
+DiagnosticRequestHandle* active_diagnostic_request_t::get_handle()
{
return handle_;
}
@@ -66,9 +74,9 @@ bool active_diagnostic_request_t::get_in_flight() const
return in_flight_;
}
-void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticRequest& request)
+void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticRequest* request)
{
- handle_ = generate_diagnostic_request(shims_, request, nullptr)
+ handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr));
}
void active_diagnostic_request_t::set_in_flight(bool val)
@@ -76,7 +84,7 @@ void active_diagnostic_request_t::set_in_flight(bool val)
in_flight_ = val;
}
-bool active_diagnostic_request_t::timed_out() const
+bool active_diagnostic_request_t::timed_out()
{
// don't use staggered start with the timeout clock
return timeout_clock_.elapsed(false);
@@ -91,14 +99,13 @@ bool active_diagnostic_request_t::timed_out() const
bool active_diagnostic_request_t::response_received() const
{
return !wait_for_multiple_responses_ &&
- handle_.completed;
+ handle_->completed;
}
/// @brief Returns true if the request has timed out waiting for a response,
/// or a sufficient number of responses has been received.
-///
-bool active_diagnostic_request_t::request_completed() const
+bool active_diagnostic_request_t::request_completed()
{
return response_received() ||
(timed_out() && diagnostic_request_sent(handle_));
-} \ No newline at end of file
+}
diff --git a/src/diagnostic/active-diagnostic-request.hpp b/src/diagnostic/active-diagnostic-request.hpp
index 1e996c03..52f4d482 100644
--- a/src/diagnostic/active-diagnostic-request.hpp
+++ b/src/diagnostic/active-diagnostic-request.hpp
@@ -23,7 +23,6 @@
#include "uds/uds_types.h"
#include "../can/can-bus-dev.hpp"
#include "../can/can-message.hpp"
-#include "diagnostic-manager.hpp"
#include "../low-can-binding.hpp"
@@ -79,25 +78,25 @@ private:
frequency_clock_t timeout_clock_; /*!< timeout_clock_ - A frequency_clock_t object to monitor how long it's been since
* this request was sent.*/
public:
- bool& operator==(const active_diagnostic_request_t& adr) const;
+ bool operator==(const active_diagnostic_request_t& b);
active_diagnostic_request_t& operator=(const active_diagnostic_request_t& adr);
active_diagnostic_request_t();
active_diagnostic_request_t(active_diagnostic_request_t&&) = default;
active_diagnostic_request_t(const active_diagnostic_request_t&) = default;
active_diagnostic_request_t(can_bus_dev_t* bus, DiagnosticRequest* request,
- const std::string& name, bool waitForMultipleResponses,
+ const std::string& name, bool wait_for_multiple_responses,
const DiagnosticResponseDecoder decoder,
const DiagnosticResponseCallback callback, float frequencyHz);
can_bus_dev_t* get_can_bus_dev();
- DiagnosticRequestHandle& get_handle();
+ DiagnosticRequestHandle* get_handle();
bool get_recurring() const;
bool get_in_flight() const;
-
+
void set_handle(DiagnosticShims& shims, DiagnosticRequest* request);
void set_in_flight(bool val);
- bool timed_out() const;
+ bool timed_out();
bool response_received() const;
- bool request_completed() const;
+ bool request_completed();
};
diff --git a/src/diagnostic/diagnostic-manager.cpp b/src/diagnostic/diagnostic-manager.cpp
index 0b59809e..b4de5543 100644
--- a/src/diagnostic/diagnostic-manager.cpp
+++ b/src/diagnostic/diagnostic-manager.cpp
@@ -75,7 +75,7 @@ void diagnostic_manager_t::cleanup_request(active_diagnostic_request_t& entry, b
entry.set_in_flight(false);
char request_string[128] = {0};
- diagnostic_request_to_string(&entry.get_handle().request,
+ diagnostic_request_to_string(&entry.get_handle()->request,
request_string, sizeof(request_string));
if(entry.get_recurring())
{
@@ -116,7 +116,7 @@ bool diagnostic_manager_t::lookup_recurring_request(const DiagnosticRequest* req
{
active_diagnostic_request_t& candidate = entry;
if(candidate.get_can_bus_dev()->get_device_name() == bus_->get_device_name() &&
- diagnostic_request_equals(&candidate.get_handle().request, request))
+ diagnostic_request_equals(&candidate.get_handle()->request, request))
{
find_and_erase(entry, recurring_requests_);
//existingEntry = entry;
@@ -171,7 +171,7 @@ bool diagnostic_manager_t::add_request(DiagnosticRequest* request, const std::st
entry.set_handle(shims_, request);
char request_string[128] = {0};
- diagnostic_request_to_string(&entry.get_handle().request, request_string,
+ diagnostic_request_to_string(&entry.get_handle()->request, request_string,
sizeof(request_string));
find_and_erase(entry, non_recurring_requests_);
@@ -213,7 +213,7 @@ bool diagnostic_manager_t::add_recurring_request(DiagnosticRequest* request, con
entry.set_handle(shims_, request);
char request_string[128] = {0};
- diagnostic_request_to_string(&entry.get_handle().request, request_string,
+ diagnostic_request_to_string(&entry.get_handle()->request, request_string,
sizeof(request_string));
find_and_erase(entry, recurring_requests_);
@@ -253,4 +253,4 @@ void diagnostic_manager_t::init_diagnostic_shims()
{
shims_ = diagnostic_init_shims(shims_logger, shims_send, NULL);
initialized_ = true;
-} \ No newline at end of file
+}
diff --git a/src/diagnostic/diagnostic-manager.hpp b/src/diagnostic/diagnostic-manager.hpp
index e4221dec..05752f6b 100644
--- a/src/diagnostic/diagnostic-manager.hpp
+++ b/src/diagnostic/diagnostic-manager.hpp
@@ -32,6 +32,7 @@
*/
#define MAX_SHIM_COUNT can_bus_t.get_can_devices().size()
+class active_diagnostic_request_t;
/**
* @brief The core structure for running the diagnostics module on the VI.