* limitations under the License.
*/
+#include <fnmatch.h>
+#include <map>
+
#include "active-diagnostic-request.hpp"
+#include "../configuration.hpp"
+
+#define ERROR_PID 0xFF
+
std::string active_diagnostic_request_t::prefix_ = "diagnostic_messages";
bool active_diagnostic_request_t::operator==(const active_diagnostic_request_t& b)
in_flight_{false}, frequency_clock_{frequency_clock_t()}, timeout_clock_{frequency_clock_t()}
{}
-active_diagnostic_request_t::active_diagnostic_request_t(std::shared_ptr<can_bus_dev_t> bus, DiagnosticRequest* request,
- const std::string& name, bool wait_for_multiple_responses,
- const DiagnosticResponseDecoder decoder,
+active_diagnostic_request_t::active_diagnostic_request_t(const std::string& 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}, recurring_{frequencyHz ? true : false}, wait_for_multiple_responses_{wait_for_multiple_responses},
return id_;
}
-std::shared_ptr<can_bus_dev_t> active_diagnostic_request_t::get_can_bus_dev()
+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
{
- return bus_;
+ if (handle_->request.has_pid)
+ return handle_->request.pid;
+ return ERROR_PID;
}
DiagnosticRequestHandle* active_diagnostic_request_t::get_handle()
return handle_;
}
-std::string& active_diagnostic_request_t::get_name()
+const std::string active_diagnostic_request_t::get_name() const
{
- return name_;
+ return active_diagnostic_request_t::prefix_ + "." + name_;
}
std::string& active_diagnostic_request_t::get_prefix()
*/
bool active_diagnostic_request_t::is_diagnostic_signal(const std::string& name)
{
- if(name.find_first_of(prefix_.c_str(), 0, prefix_.size()))
+ const std::string p = active_diagnostic_request_t::prefix_ + "*";
+ if(::fnmatch(p.c_str(), name.c_str(), FNM_CASEFOLD) == 0)
return true;
return false;
}