summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-04-21 15:42:48 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-04-21 15:42:48 +0200
commitf0880c9212e3fb1c2abe8dbbcd376da1279901e6 (patch)
tree2b2042042c77e1e753cddb30e8ee22d7416f3f55
parent1a67a9c8647c7fa48ee435f033f336e5f83ac270 (diff)
Diagnostic messages subscription simplified.
Remove useless function. Change-Id: I6638c3033cfeea643b29c1280d7f5785371cd342 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--CAN-binder/low-can-binding/configuration.cpp40
-rw-r--r--CAN-binder/low-can-binding/configuration.hpp1
-rw-r--r--CAN-binder/low-can-binding/low-can-binding.cpp5
3 files changed, 20 insertions, 26 deletions
diff --git a/CAN-binder/low-can-binding/configuration.cpp b/CAN-binder/low-can-binding/configuration.cpp
index 8a50cbc..a94809f 100644
--- a/CAN-binder/low-can-binding/configuration.cpp
+++ b/CAN-binder/low-can-binding/configuration.cpp
@@ -87,6 +87,24 @@ void configuration_t::set_active_message_set(uint8_t id)
active_message_set_ = id;
}
+
+diagnostic_message_t* configuration_t::get_diagnostic_message(std::string message_name) const
+{
+ std::vector<diagnostic_message_t*> found;
+ configuration_t::instance().find_diagnostic_messages(build_DynamicField(message_name), found);
+ if(! found.empty())
+ return found.front();
+ return nullptr;
+}
+
+DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(std::string message_name) const
+{
+ 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;
+}
+
/// @brief return diagnostic messages name found searching through diagnostic messages list.
///
/// @param[in] key - can contain numeric or string value in order to search against
@@ -110,28 +128,6 @@ void configuration_t::find_diagnostic_messages(const openxc_DynamicField &key, s
DEBUG(binder_interface, "find_diagnostic_messages: Found %d signal(s)", (int)found_signals.size());
}
-diagnostic_message_t* configuration_t::get_diagnostic_message(std::string message_name) const
-{
- std::vector<diagnostic_message_t*> found;
- configuration_t::instance().find_diagnostic_messages(build_DynamicField(message_name), found);
- if(! found.empty())
- return found.front();
- return nullptr;
-}
-
-DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(diagnostic_message_t* diag_msg) const
-{
- return new DiagnosticRequest(diag_msg->build_diagnostic_request());
-}
-
-DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(std::string message_name) const
-{
- diagnostic_message_t* diag_msg = get_diagnostic_message(message_name);
- if( diag_msg != nullptr)
- return new DiagnosticRequest(diag_msg->build_diagnostic_request());
- return nullptr;
-}
-
/// @brief return signals name found searching through CAN signals list.
///
/// @param[in] key - can contain numeric or string value in order to search against
diff --git a/CAN-binder/low-can-binding/configuration.hpp b/CAN-binder/low-can-binding/configuration.hpp
index 535ab8d..cbb5ac2 100644
--- a/CAN-binder/low-can-binding/configuration.hpp
+++ b/CAN-binder/low-can-binding/configuration.hpp
@@ -86,7 +86,6 @@ class configuration_t
void find_diagnostic_messages(const openxc_DynamicField &key, std::vector<diagnostic_message_t*>& found_signals);
diagnostic_message_t* get_diagnostic_message(std::string message_name) const;
- DiagnosticRequest* get_request_from_diagnostic_message(diagnostic_message_t* diag_msg) const;
DiagnosticRequest* get_request_from_diagnostic_message(std::string message_name) const;
void find_can_signals(const openxc_DynamicField &key, std::vector<can_signal_t*>& found_signals);
diff --git a/CAN-binder/low-can-binding/low-can-binding.cpp b/CAN-binder/low-can-binding/low-can-binding.cpp
index 07b3f1e..6f361af 100644
--- a/CAN-binder/low-can-binding/low-can-binding.cpp
+++ b/CAN-binder/low-can-binding/low-can-binding.cpp
@@ -141,13 +141,12 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
int ret;
if (active_diagnostic_request_t::is_diagnostic_signal(sig))
{
- diagnostic_message_t* diag_msg = configuration_t::instance().get_diagnostic_message(sig);
- DiagnosticRequest* diag_req = configuration_t::instance().get_request_from_diagnostic_message(diag_msg);
+ DiagnosticRequest* diag_req = configuration_t::instance().get_request_from_diagnostic_message(sig);
// If the requested diagnostic message isn't supported by the car then unssubcribe.
// no matter what we want, worse case will be a fail unsubscription but at least we don't
// poll a PID for nothing.
- if(diag_msg->get_supported() && subscribe)
+ if(diag_req != nullptr && subscribe)
{
float frequency = diag_msg->get_frequency();
subscribe = configuration_t::instance().get_diagnostic_manager().add_recurring_request(