summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-15 23:07:34 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 17:21:57 +0100
commit865c6c6d6f4174c5874e4cd5136832c25a3b1198 (patch)
tree58ef5ee4b6b3cbecb03920ec666a45f2509bfb50 /src
parentdaa713ab23d8bb8192fc4e86aaf6720e830cdab9 (diff)
Simplification of checking Diagnostic response.
A CAN message will be considered as a Diagnostic response when its arbitration ID is between standardized 0x7E8 and 0x7EF. Checking which request belong to that response will done in later methods Change-Id: I7a093edf44b62a4552b90fe3d8935f94dc677cf4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/can/can-bus.cpp2
-rw-r--r--src/diagnostic/diagnostic-manager.cpp38
-rw-r--r--src/diagnostic/diagnostic-manager.hpp3
3 files changed, 17 insertions, 26 deletions
diff --git a/src/can/can-bus.cpp b/src/can/can-bus.cpp
index 7c6ae429..18417f9c 100644
--- a/src/can/can-bus.cpp
+++ b/src/can/can-bus.cpp
@@ -179,7 +179,7 @@ void can_bus_t::can_decode_message()
new_can_message_cv_.wait(can_message_lock);
can_message = next_can_message();
- active_diagnostic_request_t* adr = configuration_t::instance().get_diagnostic_manager().is_diagnostic_response(can_message);
+ if(configuration_t::instance().get_diagnostic_manager().is_diagnostic_response(can_message))
if(adr != nullptr)
process_diagnostic_signals(adr, can_message);
else
diff --git a/src/diagnostic/diagnostic-manager.cpp b/src/diagnostic/diagnostic-manager.cpp
index 1477b2b9..31eed0e2 100644
--- a/src/diagnostic/diagnostic-manager.cpp
+++ b/src/diagnostic/diagnostic-manager.cpp
@@ -254,29 +254,6 @@ bool diagnostic_manager_t::add_recurring_request(DiagnosticRequest* request, con
return added;
}
-bool diagnostic_manager_t::is_diagnostic_response(const active_diagnostic_request_t& adr, const can_message_t& cm) const
-{
- if(cm.get_id() == adr.get_id() + DIAGNOSTIC_RESPONSE_ARBITRATION_ID_OFFSET)
- return true;
- DEBUG(binder_interface, "Doesn't find an active diagnostic request that matches.");
- return false;
-}
-
-active_diagnostic_request_t* diagnostic_manager_t::is_diagnostic_response(const can_message_t& can_message)
-{
- for (auto& entry : non_recurring_requests_)
- {
- if(is_diagnostic_response(*entry, can_message))
- return entry;
- }
-
- for (auto& entry : recurring_requests_)
- {
- if(is_diagnostic_response(*entry, can_message))
- return entry;
- }
- return nullptr;
-}
openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response) const
{
@@ -369,6 +346,21 @@ int diagnostic_manager_t::send_request(sd_event_source *s, uint64_t usec, void *
return -1;
}
+
+/// @brief Tell if the CAN message received is a diagnostic response.
+/// Request broadcast ID use 0x7DF and assigned ID goes from 0x7E0 to Ox7E7. That allows up to 8 ECU to respond
+/// at the same time. The response is the assigned ID + 0x8, so response ID can goes from 0x7E8 to 0x7EF.
+///
+/// @param[in] cm - CAN message received from the socket.
+///
+/// @return True if the active diagnostic request match the response.
+bool diagnostic_manager_t::is_diagnostic_response(const can_message_t& cm)
+{
+ if (cm.get_id() >= 0x7e8 && cm.get_id() <= 0x7ef)
+ return true;
+ return false;
+}
+
DiagnosticShims& diagnostic_manager_t::get_shims()
{
return shims_;
diff --git a/src/diagnostic/diagnostic-manager.hpp b/src/diagnostic/diagnostic-manager.hpp
index ff055d54..1db83636 100644
--- a/src/diagnostic/diagnostic-manager.hpp
+++ b/src/diagnostic/diagnostic-manager.hpp
@@ -88,12 +88,11 @@ public:
bool waitForMultipleResponses, const DiagnosticResponseDecoder decoder,
const DiagnosticResponseCallback callback, float frequencyHz);
- bool is_diagnostic_response(const active_diagnostic_request_t& adr, const can_message_t& cm) const;
- active_diagnostic_request_t* is_diagnostic_response(const can_message_t& can_message);
openxc_VehicleMessage relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response) const;
bool conflicting(active_diagnostic_request_t* request, active_diagnostic_request_t* candidate) const;
bool clear_to_send(active_diagnostic_request_t* request) const;
static int send_request(sd_event_source *s, uint64_t usec, void *userdata);
+ bool is_diagnostic_response(const can_message_t& cm);
};