summaryrefslogtreecommitdiffstats
path: root/src/diagnostic
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-10 16:08:06 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 17:10:41 +0100
commit065a5bdef8c37f8b0466f63e48443dab31e86431 (patch)
tree47b554a3fe13ed99fcd87f298e01b2607f0f6601 /src/diagnostic
parent093d7a35c23c65ffef888ded40aea9e77f0e4975 (diff)
We doesn't modify member once getted, we can use const return
and const method. Change-Id: I0f7465af74b1c9a546af45a0d1eea33c93537e0c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/diagnostic')
-rw-r--r--src/diagnostic/diagnostic-message.cpp27
-rw-r--r--src/diagnostic/diagnostic-message.hpp8
2 files changed, 26 insertions, 9 deletions
diff --git a/src/diagnostic/diagnostic-message.cpp b/src/diagnostic/diagnostic-message.cpp
index bd76de0b..62e97b8f 100644
--- a/src/diagnostic/diagnostic-message.cpp
+++ b/src/diagnostic/diagnostic-message.cpp
@@ -43,16 +43,21 @@ uint32_t obd2_signal_t::get_pid()
return (uint32_t)pid_;
}
-std::string& obd2_signal_t::get_generic_name()
+const std::string& obd2_signal_t::get_generic_name() const
{
return generic_name_;
}
-std::string obd2_signal_t::get_name()
+const std::string obd2_signal_t::get_name() const
{
return prefix_ + "." + generic_name_;
}
+const std::string& obd2_signal_t::get_prefix() const
+{
+ return prefix_;
+}
+
void obd2_signal_t::set_prefix(std::string val)
{
prefix_ = val;
@@ -102,11 +107,21 @@ bool obd2_signal_t::is_obd2_response(can_message_t can_message)
return false;
}
-void obd2_signal_t::add_request(int pid)
+/**
+ * @brief Build a DiagnosticRequest struct to be passed
+ * to diagnostic manager instance.
+ */
+const DiagnosticRequest obd2_signal_t::build_diagnostic_request()
{
- DiagnosticRequest request = {
- arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
- mode: 0x1, has_pid: true, pid: pid_ };
+ return {/*arbitration_id: */OBD2_FUNCTIONAL_BROADCAST_ID,
+ /*mode: */0x1,
+ /*has_pid: */true,
+ /*pid: */pid_,
+ /*pid_length: */0,
+ /*payload[]: */{0},
+ /*payload_length: */0,
+ /*no_frame_padding: */false,
+ /*DiagnosticRequestType: */DiagnosticRequestType::DIAGNOSTIC_REQUEST_TYPE_PID };
}
/**
diff --git a/src/diagnostic/diagnostic-message.hpp b/src/diagnostic/diagnostic-message.hpp
index 534b9a59..8301917f 100644
--- a/src/diagnostic/diagnostic-message.hpp
+++ b/src/diagnostic/diagnostic-message.hpp
@@ -59,11 +59,13 @@ class obd2_signal_t {
obd2_signal_t(uint8_t pid, const char* generic_name, const int min_, const int max_, enum UNIT unit, int frequency, bool supported);
uint32_t get_pid();
- std::string& get_generic_name();
- std::string get_name();
+ const std::string& get_generic_name() const;
+ const std::string get_name() const;
+ const std::string& get_prefix() const;
void set_prefix(std::string val);
- void add_request(int pid);
+
+ const DiagnosticRequest build_diagnostic_request();
bool is_obd2_response(can_message_t can_message);
bool is_obd2_request(DiagnosticRequest *request);