summaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-02 19:48:24 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-02 19:48:24 +0200
commit9ecd09263535843e287048d299ca5bdfc85d18d9 (patch)
treef6c424072a154775ff890cbbf90f8b48d9319d42 /CAN-binder/low-can-binding
parent4ab2164774bdb9a29b2f180a9013c26c0155628d (diff)
Remove pointer generator that make memory leaks.
Only have 1 place where to generate a pointer from a DiagnosticRequest is in low-can-cb.cpp when subscribing. Else now using reference instead of raw pointer. Change-Id: I7fd2f3d30afa90017b945e6b711922036123b6d3 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding')
-rw-r--r--CAN-binder/low-can-binding/binding/application.cpp18
-rw-r--r--CAN-binder/low-can-binding/binding/application.hpp2
-rw-r--r--CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp4
-rw-r--r--CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp2
-rw-r--r--CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp10
-rw-r--r--CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp3
6 files changed, 10 insertions, 29 deletions
diff --git a/CAN-binder/low-can-binding/binding/application.cpp b/CAN-binder/low-can-binding/binding/application.cpp
index b916523e..6e6353b8 100644
--- a/CAN-binder/low-can-binding/binding/application.cpp
+++ b/CAN-binder/low-can-binding/binding/application.cpp
@@ -76,21 +76,3 @@ void application_t::set_active_message_set(uint8_t id)
{
active_message_set_ = id;
}
-
-
-std::shared_ptr<diagnostic_message_t> application_t::get_diagnostic_message(const std::string& message_name) const
-{
- struct utils::signals_found found;
- found = utils::signals_manager_t::instance().find_signals(build_DynamicField(message_name));
- if(! found.diagnostic_messages.empty())
- return found.diagnostic_messages.front();
- return nullptr;
-}
-
-DiagnosticRequest* application_t::get_request_from_diagnostic_message(const std::string& message_name) const
-{
- std::shared_ptr<diagnostic_message_t> diag_msg = get_diagnostic_message(message_name);
- if( diag_msg != nullptr && diag_msg->get_supported())
- return new DiagnosticRequest(diag_msg->build_diagnostic_request());
- return nullptr;
-}
diff --git a/CAN-binder/low-can-binding/binding/application.hpp b/CAN-binder/low-can-binding/binding/application.hpp
index 50b2375d..5fa64782 100644
--- a/CAN-binder/low-can-binding/binding/application.hpp
+++ b/CAN-binder/low-can-binding/binding/application.hpp
@@ -78,8 +78,6 @@ class application_t
void set_active_message_set(uint8_t id);
- std::shared_ptr<diagnostic_message_t> get_diagnostic_message(const std::string& message_name) const;
- DiagnosticRequest* get_request_from_diagnostic_message(const std::string& message_name) const;
/*
/// TODO: implement this function as method into can_bus class
/// @brief Pre initialize actions made before CAN bus initialization
diff --git a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp
index 61775b8e..f503e0a5 100644
--- a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp
+++ b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp
@@ -65,14 +65,14 @@ active_diagnostic_request_t::active_diagnostic_request_t()
socket_{}
{}
-active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus, DiagnosticRequest* request,
+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)
: bus_{bus},
- id_{request->arbitration_id},
+ id_{id},
handle_{nullptr},
name_{name},
decoder_{decoder},
diff --git a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp
index a1b8ab5b..d263a2d2 100644
--- a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp
+++ b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp
@@ -91,7 +91,7 @@ public:
active_diagnostic_request_t();
active_diagnostic_request_t(active_diagnostic_request_t&&) = default;
- active_diagnostic_request_t(const std::string& bus, DiagnosticRequest* request,
+ 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);
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
index fd4fbd29..ac91ae5b 100644
--- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
+++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
@@ -246,13 +246,13 @@ void diagnostic_manager_t::cleanup_active_requests(bool force)
///
/// @param[in] request - Search key, method will go through recurring list to see if it find that request
/// holded by the DiagnosticHandle member.
-active_diagnostic_request_t* diagnostic_manager_t::find_recurring_request(const DiagnosticRequest* request)
+active_diagnostic_request_t* diagnostic_manager_t::find_recurring_request(DiagnosticRequest& request)
{
for (auto& entry : recurring_requests_)
{
if(entry != nullptr)
{
- if(diagnostic_request_equals(&entry->get_handle()->request, request))
+ if(diagnostic_request_equals(&entry->get_handle()->request, &request))
{return entry;}
}
}
@@ -297,7 +297,7 @@ active_diagnostic_request_t* diagnostic_manager_t::add_request(DiagnosticRequest
{
// TODO: implement Acceptance Filter
// if(updateRequiredAcceptanceFilters(bus, request)) {
- active_diagnostic_request_t* entry = new active_diagnostic_request_t(bus_, request, name,
+ active_diagnostic_request_t* entry = new active_diagnostic_request_t(bus_, request->arbitration_id, name,
wait_for_multiple_responses, decoder, callback, 0);
entry->set_handle(shims_, request);
@@ -393,11 +393,11 @@ active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(Diagnos
cleanup_active_requests(false);
- if(find_recurring_request(request) == nullptr)
+ if(find_recurring_request(*request) == nullptr)
{
if(recurring_requests_.size() <= MAX_SIMULTANEOUS_DIAG_REQUESTS)
{
- entry = new active_diagnostic_request_t(bus_, request, name,
+ entry = new active_diagnostic_request_t(bus_, request->arbitration_id, name,
wait_for_multiple_responses, decoder, callback, frequencyHz);
recurring_requests_.push_back(entry);
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
index d52ffe97..4c023c67 100644
--- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
+++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
@@ -67,12 +67,13 @@ public:
const std::string get_bus_device_name() const;
active_diagnostic_request_t* get_last_recurring_requests() const;
DiagnosticShims& get_shims();
+ bool is_active_requests_running();
void find_and_erase(active_diagnostic_request_t* entry, std::vector<active_diagnostic_request_t*>& requests_list);
void cancel_request(active_diagnostic_request_t* entry);
void cleanup_request(active_diagnostic_request_t* entry, bool force);
void cleanup_active_requests(bool force);
- active_diagnostic_request_t* find_recurring_request(const DiagnosticRequest* request);
+ active_diagnostic_request_t* find_recurring_request(DiagnosticRequest& request);
// Subscription parts
active_diagnostic_request_t* add_request(DiagnosticRequest* request, const std::string& name,