summaryrefslogtreecommitdiffstats
path: root/CAN-binder
diff options
context:
space:
mode:
Diffstat (limited to 'CAN-binder')
-rw-r--r--CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp48
-rw-r--r--CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp7
-rw-r--r--CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp39
-rw-r--r--CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp9
4 files changed, 2 insertions, 101 deletions
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 4018b6b..e657456 100644
--- a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp
+++ b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.cpp
@@ -43,7 +43,6 @@ active_diagnostic_request_t& active_diagnostic_request_t::operator=(const active
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_;
}
@@ -60,7 +59,6 @@ active_diagnostic_request_t::active_diagnostic_request_t()
callback_{nullptr},
recurring_{false},
wait_for_multiple_responses_{false},
- in_flight_{false},
frequency_clock_{frequency_clock_t()},
timeout_clock_{frequency_clock_t()}
{}
@@ -79,7 +77,6 @@ active_diagnostic_request_t::active_diagnostic_request_t(const std::string& bus,
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)}
{}
@@ -89,11 +86,6 @@ uint32_t active_diagnostic_request_t::get_id() const
return id_;
}
-const std::shared_ptr<can_bus_dev_t> active_diagnostic_request_t::get_can_bus_dev() const
-{
- return can_bus_t::get_can_device(bus_);
-}
-
uint16_t active_diagnostic_request_t::get_pid() const
{
if (handle_->request.has_pid)
@@ -131,11 +123,6 @@ bool active_diagnostic_request_t::get_recurring() const
return recurring_;
}
-bool active_diagnostic_request_t::get_in_flight() const
-{
- return in_flight_;
-}
-
frequency_clock_t& active_diagnostic_request_t::get_frequency_clock()
{
return frequency_clock_;
@@ -156,11 +143,6 @@ void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticR
handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr));
}
-void active_diagnostic_request_t::set_in_flight(bool val)
-{
- in_flight_ = val;
-}
-
///
/// @brief Check if requested signal name is a diagnostic message. If the name
/// begin with the diagnostic message prefix then true else false.
@@ -177,26 +159,6 @@ bool active_diagnostic_request_t::is_diagnostic_signal(const std::string& name)
return false;
}
-/// @brief Check is the request should be sent or not
-///
-/// @return true if the request is not running or recurring nor completed,
-/// or it's recurring, its clock elapsed
-/// so it's time to send another one.
-bool active_diagnostic_request_t::should_send()
-{
- return !in_flight_ && ( (!recurring_ && !request_completed()) ||
- (recurring_ && frequency_clock_.elapsed(true)) );
-}
-
-/// @brief check if the timeout clock has elapsed
-///
-/// @return true if elapsed, so it is a timeout, else false.
-bool active_diagnostic_request_t::timed_out()
-{
- // don't use staggered start with the timeout clock
- return timeout_clock_.elapsed(false);
-}
-
/// @brief Returns true if a sufficient response has been received for a
/// diagnostic request.
///
@@ -206,13 +168,5 @@ bool active_diagnostic_request_t::timed_out()
bool active_diagnostic_request_t::response_received() const
{
return !wait_for_multiple_responses_ &&
- 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()
-{
- return response_received() ||
- (timed_out() && diagnostic_request_sent(handle_));
+ handle_->completed && handle_->success;
}
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 e9e660d..c295bed 100644
--- a/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp
+++ b/CAN-binder/low-can-binding/diagnostic/active-diagnostic-request.hpp
@@ -80,7 +80,6 @@ private:
bool wait_for_multiple_responses_; ///< wait_for_multiple_responses_ - False by default, when any response is received for a request
///< it will be removed from the active list. If true, the request will remain active until the timeout
///< clock expires, to allow it to receive multiple response (e.g. to a functional broadcast request).
- bool in_flight_; ///< in_flight_ - True if the request has been sent and we are waiting for a response.
frequency_clock_t frequency_clock_; ///< frequency_clock_ - A frequency_clock_t object to control the send rate for a
///< recurring request. If the request is not reecurring, this attribute is not used.
frequency_clock_t timeout_clock_; ///< timeout_clock_ - A frequency_clock_t object to monitor how long it's been since
@@ -105,19 +104,13 @@ public:
DiagnosticResponseDecoder& get_decoder();
DiagnosticResponseCallback& get_callback();
bool get_recurring() const;
- bool get_in_flight() const;
frequency_clock_t& get_frequency_clock();
frequency_clock_t& get_timeout_clock();
utils::socketcan_bcm_t& get_socket();
void set_handle(DiagnosticShims& shims, DiagnosticRequest* request);
- void set_in_flight(bool val);
static bool is_diagnostic_signal(const std::string& name);
- bool should_send();
-
- bool timed_out();
bool response_received() const;
- bool request_completed();
};
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
index 36413d9..c4be28f 100644
--- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
+++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
@@ -245,10 +245,8 @@ void diagnostic_manager_t::cancel_request(active_diagnostic_request_t* entry)
/// @param[in] force - Force the cleaning or not ?
void diagnostic_manager_t::cleanup_request(active_diagnostic_request_t* entry, bool force)
{
- if((force || (entry != nullptr && entry->get_in_flight() && entry->request_completed())))
+ if((force || (entry != nullptr && entry->response_received())))
{
- entry->set_in_flight(false);
-
char request_string[128] = {0};
diagnostic_request_to_string(&entry->get_handle()->request,
request_string, sizeof(request_string));
@@ -476,41 +474,6 @@ active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(Diagnos
return entry;
}
-/// @brief Returns true if there are two active requests running for the same arbitration ID.
-bool diagnostic_manager_t::conflicting(active_diagnostic_request_t* request, active_diagnostic_request_t* candidate) const
-{
- return (candidate->get_in_flight() && candidate != request &&
- candidate->get_can_bus_dev() == request->get_can_bus_dev() &&
- candidate->get_id() == request->get_id());
-}
-
-
-/// @brief Returns true if there are no other active requests to the same arbitration ID
-/// and if there aren't more than 8 requests in flight at the same time.
-bool diagnostic_manager_t::clear_to_send(active_diagnostic_request_t* request) const
-{
- int total_in_flight = 0;
- for ( auto entry : non_recurring_requests_)
- {
- if(conflicting(request, entry))
- return false;
- if(entry->get_in_flight())
- total_in_flight++;
- }
-
- for ( auto entry : recurring_requests_)
- {
- if(conflicting(request, entry))
- return false;
- if(entry->get_in_flight())
- total_in_flight++;
- }
-
- if(total_in_flight > MAX_SIMULTANEOUS_IN_FLIGHT_REQUESTS)
- return false;
- return true;
-}
-
/// @brief Will decode the diagnostic response and build the final openxc_VehicleMessage to return.
///
/// @param[in] adr - A pointer to an active diagnostic request holding a valid diagnostic handle
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
index f9f2018..bcee3dc 100644
--- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
+++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
@@ -78,9 +78,6 @@ public:
void cleanup_active_requests(bool force);
active_diagnostic_request_t* find_recurring_request(const DiagnosticRequest* request);
- void checkSupportedPids(const active_diagnostic_request_t& request,
- const DiagnosticResponse& response, float parsedPayload);
-
// Subscription parts
active_diagnostic_request_t* add_request(DiagnosticRequest* request, const std::string name,
bool waitForMultipleResponses, const DiagnosticResponseDecoder decoder,
@@ -90,12 +87,6 @@ public:
bool waitForMultipleResponses, const DiagnosticResponseDecoder decoder,
const DiagnosticResponseCallback callback, float frequencyHz);
- // Sendig requests part
- bool conflicting(active_diagnostic_request_t* request, active_diagnostic_request_t* candidate) const;
- bool clear_to_send(active_diagnostic_request_t* request) const;
- int reschedule_request(sd_event_source *s, uint64_t usec, active_diagnostic_request_t* adr);
- static int send_request(sd_event_source *s, uint64_t usec, void *userdata);
-
// Decoding part
openxc_VehicleMessage relay_diagnostic_response(active_diagnostic_request_t* adr, const DiagnosticResponse& response);
openxc_VehicleMessage relay_diagnostic_handle(active_diagnostic_request_t* entry, const can_message_t& cm);