aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-10 18:39:25 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-10 18:45:56 +0200
commitd253ada94487232ccd33b68a69fd44ff7840fab7 (patch)
tree67f5959138d0ddcad413f9ee692d087200e0b4df /CAN-binder/low-can-binding
parent3e2be4237ac6f3e8bcec8b10d295182cefe67330 (diff)
Use a tree instead of separated object lists. WIP
Now we respect JSON description file, which is can_message_set contains can_message_definition which contains can_signals. Diagnostic messages aren't processed for now. Change-Id: I94aaf5eded14dd84395bd4fd749df58dee5f533e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding')
-rw-r--r--CAN-binder/low-can-binding/binding/configuration-generated.cpp206
-rw-r--r--CAN-binder/low-can-binding/binding/configuration.cpp15
-rw-r--r--CAN-binder/low-can-binding/binding/configuration.hpp13
-rw-r--r--CAN-binder/low-can-binding/can/can-decoder.cpp2
-rw-r--r--CAN-binder/low-can-binding/can/can-decoder.hpp2
-rw-r--r--CAN-binder/low-can-binding/can/can-message-definition.cpp56
-rw-r--r--CAN-binder/low-can-binding/can/can-message-definition.hpp16
-rw-r--r--CAN-binder/low-can-binding/can/can-message-set.cpp28
-rw-r--r--CAN-binder/low-can-binding/can/can-message-set.hpp12
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.cpp37
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.hpp13
11 files changed, 245 insertions, 155 deletions
diff --git a/CAN-binder/low-can-binding/binding/configuration-generated.cpp b/CAN-binder/low-can-binding/binding/configuration-generated.cpp
index c96a103a..3ab911a9 100644
--- a/CAN-binder/low-can-binding/binding/configuration-generated.cpp
+++ b/CAN-binder/low-can-binding/binding/configuration-generated.cpp
@@ -3,117 +3,103 @@
configuration_t::configuration_t()
:can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}}
- , can_message_set_{{0, "example", 0, 1, 5, 0, 20}}
- , can_message_definition_
- {
- {
- can_message_definition_t{0, "can0", 0x620, can_message_format_t::STANDARD, frequency_clock_t(0.00000f), true}
- }
- }
- , can_signals_
- {
- {
- {
- 0,
- 0,
- "doors.coffer.open",
- 56,
- 1,
- 1.00000f,
- 0,
- 0,
- 0,
- frequency_clock_t(0.00000f),
- false,
- false,
- {
- },
- false,
- decoder_t::booleanDecoder,
- nullptr,
- false
- },
- {
- 0,
- 0,
- "doors.driver.open",
- 46,
- 1,
- 1.00000f,
- 0,
- 0,
- 0,
- frequency_clock_t(0.00000f),
- false,
- false,
+ , can_message_set_{
+ can_message_set_t{0, "example", 0, 1, 5, 0, 20, {
+ {std::make_shared<can_message_definition_t>(can_message_definition_t{"can0", 0x620, can_message_format_t::STANDARD, frequency_clock_t(0.00000f), true,
{
- },
- false,
- decoder_t::booleanDecoder,
- nullptr,
- false
- },
- {
- 0,
- 0,
- "doors.passenger.open",
- 47,
- 1,
- 1.00000f,
- 0,
- 0,
- 0,
- frequency_clock_t(0.00000f),
- false,
- false,
- {
- },
- false,
- decoder_t::booleanDecoder,
- nullptr,
- false
- },
- {
- 0,
- 0,
- "doors.rearleft.open",
- 54,
- 1,
- 1.00000f,
- 0,
- 0,
- 0,
- frequency_clock_t(0.00000f),
- false,
- false,
- {
- },
- false,
- decoder_t::booleanDecoder,
- nullptr,
- false
- },
- {
- 0,
- 0,
- "doors.rearright.open",
- 55,
- 4,
- 1.00000f,
- 0,
- 0,
- 0,
- frequency_clock_t(0.00000f),
- false,
- false,
- {
- },
- false,
- decoder_t::booleanDecoder,
- nullptr,
- false
- }
- }
+ {std::make_shared<can_signal_t>(
+ can_signal_t{
+ "doors.coffer.open",
+ 56,
+ 1,
+ 1.00000f,
+ 0,
+ 0,
+ 0,
+ frequency_clock_t(0.00000f),
+ false,
+ false,
+ {},
+ false,
+ decoder_t::booleanDecoder,
+ nullptr,
+ false
+ })},
+ {std::make_shared<can_signal_t> (
+ can_signal_t{
+ "doors.driver.open",
+ 46,
+ 1,
+ 1.00000f,
+ 0,
+ 0,
+ 0,
+ frequency_clock_t(0.00000f),
+ false,
+ false,
+ {},
+ false,
+ decoder_t::booleanDecoder,
+ nullptr,
+ false
+ })},
+ {std::make_shared<can_signal_t> (
+ can_signal_t{
+ "doors.passenger.open",
+ 47,
+ 1,
+ 1.00000f,
+ 0,
+ 0,
+ 0,
+ frequency_clock_t(0.00000f),
+ false,
+ false,
+ {},
+ false,
+ decoder_t::booleanDecoder,
+ nullptr,
+ false
+ })},
+ {std::make_shared<can_signal_t> (
+ can_signal_t{
+ "doors.rearleft.open",
+ 54,
+ 1,
+ 1.00000f,
+ 0,
+ 0,
+ 0,
+ frequency_clock_t(0.00000f),
+ false,
+ false,
+ {},
+ false,
+ decoder_t::booleanDecoder,
+ nullptr,
+ false
+ })},
+ {std::make_shared<can_signal_t> (
+ can_signal_t{
+ "doors.rearright.open",
+ 55,
+ 4,
+ 1.00000f,
+ 0,
+ 0,
+ 0,
+ frequency_clock_t(0.00000f),
+ false,
+ false,
+ {},
+ false,
+ decoder_t::booleanDecoder,
+ nullptr,
+ false
+ })}
+ }
+ })}
+ }}
}
, diagnostic_messages_
{
diff --git a/CAN-binder/low-can-binding/binding/configuration.cpp b/CAN-binder/low-can-binding/binding/configuration.cpp
index 0c0c9ba8..da9d16b2 100644
--- a/CAN-binder/low-can-binding/binding/configuration.cpp
+++ b/CAN-binder/low-can-binding/binding/configuration.cpp
@@ -52,9 +52,9 @@ const std::vector<can_message_set_t>& configuration_t::get_can_message_set()
return can_message_set_;
}
-std::vector<can_signal_t>& configuration_t::get_can_signals()
+std::vector<std::shared_ptr<can_signal_t> > configuration_t::get_can_signals()
{
- return can_signals_[active_message_set_];
+ return can_message_set_[active_message_set_].get_can_signals();
}
std::vector<diagnostic_message_t>& configuration_t::get_diagnostic_messages()
@@ -62,14 +62,9 @@ std::vector<diagnostic_message_t>& configuration_t::get_diagnostic_messages()
return diagnostic_messages_[active_message_set_];
}
-const std::vector<can_message_definition_t>& configuration_t::get_can_message_definition()
+std::vector<std::shared_ptr<can_message_definition_t> > configuration_t::get_can_message_definition()
{
- return can_message_definition_[active_message_set_];
-}
-
-can_message_definition_t& configuration_t::get_can_message_definition(std::uint8_t message_set_id, std::uint8_t message_id)
-{
- return can_message_definition_[message_set_id][message_id];
+ return can_message_set_[active_message_set_].get_can_message_definition();
}
uint32_t configuration_t::get_signal_id(diagnostic_message_t& sig) const
@@ -79,7 +74,7 @@ uint32_t configuration_t::get_signal_id(diagnostic_message_t& sig) const
uint32_t configuration_t::get_signal_id(can_signal_t& sig) const
{
- return sig.get_message().get_id();
+ return sig.get_message()->get_id();
}
void configuration_t::set_active_message_set(uint8_t id)
diff --git a/CAN-binder/low-can-binding/binding/configuration.hpp b/CAN-binder/low-can-binding/binding/configuration.hpp
index dd25a206..44881645 100644
--- a/CAN-binder/low-can-binding/binding/configuration.hpp
+++ b/CAN-binder/low-can-binding/binding/configuration.hpp
@@ -20,11 +20,11 @@
#include <map>
#include <vector>
#include <string>
-#include <fcntl.h>
+#include <memory>
#include "../can/can-bus.hpp"
+#include "../can/can-message-set.hpp"
#include "../can/can-signals.hpp"
-#include "../can/can-message.hpp"
#include "../diagnostic/diagnostic-manager.hpp"
#include "low-can-hat.hpp"
@@ -48,8 +48,8 @@ class configuration_t
uint8_t active_message_set_ = 0; ///< Which is the active message set ? Default to 0.
std::vector<can_message_set_t> can_message_set_; ///< Vector holding all message set from JSON signals description file
- std::vector<std::vector<can_message_definition_t>> can_message_definition_; ///< Vector of vector holding all can message definition from JSON signals description file. This describe a CAN message. First vector map to message set
- std::vector<std::vector<can_signal_t>> can_signals_; ///< Vector of vector holding all can signasl from JSON signals description file. A CAN signal is a part of a CAN message. First vector map to message set
+ //std::vector<std::vector<can_message_definition_t>> can_message_definition_; ///< Vector of vector holding all can message definition from JSON signals description file. This describe a CAN message. First vector map to message set
+ //std::vector<std::vector<can_signal_t>> can_signals_; ///< Vector of vector holding all can signasl from JSON signals description file. A CAN signal is a part of a CAN message. First vector map to message set
std::vector<std::vector<diagnostic_message_t>> diagnostic_messages_; ///< Vector of vector holding all diagnostics messages from JSON signals description file. First vector map to message set
configuration_t(); ///< Private constructor with implementation generated by the AGL generator.
@@ -69,14 +69,13 @@ class configuration_t
const std::vector<can_message_set_t>& get_can_message_set();
- std::vector<can_signal_t>& get_can_signals();
+ std::vector<std::shared_ptr<can_signal_t> > get_can_signals();
std::vector<diagnostic_message_t>& get_diagnostic_messages();
const std::vector<std::string>& get_signals_prefix() const;
- const std::vector<can_message_definition_t>& get_can_message_definition();
- can_message_definition_t& get_can_message_definition(std::uint8_t message_set_id, std::uint8_t message_id);
+ std::vector<std::shared_ptr<can_message_definition_t> > get_can_message_definition();
uint32_t get_signal_id(diagnostic_message_t& sig) const;
diff --git a/CAN-binder/low-can-binding/can/can-decoder.cpp b/CAN-binder/low-can-binding/can/can-decoder.cpp
index 2ccbbb8e..419eac1b 100644
--- a/CAN-binder/low-can-binding/can/can-decoder.cpp
+++ b/CAN-binder/low-can-binding/can/can-decoder.cpp
@@ -154,7 +154,7 @@ openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal,
/// string or boolean.
///
openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_message_t& message,
- const std::vector<can_signal_t>& signals, bool* send)
+ const std::vector<std::shared_ptr<can_signal_t> >& signals, bool* send)
{
float value = decoder_t::parseSignalBitfield(signal, message);
DEBUG(binder_interface, "%s: Decoded message from parseSignalBitfield: %f", __FUNCTION__, value);
diff --git a/CAN-binder/low-can-binding/can/can-decoder.hpp b/CAN-binder/low-can-binding/can/can-decoder.hpp
index d626eaad..1e7efc6b 100644
--- a/CAN-binder/low-can-binding/can/can-decoder.hpp
+++ b/CAN-binder/low-can-binding/can/can-decoder.hpp
@@ -36,7 +36,7 @@ public:
float value, bool* send);
static openxc_DynamicField translateSignal(can_signal_t& signal, const can_message_t& message,
- const std::vector<can_signal_t>& signals, bool* send);
+ const std::vector<std::shared_ptr<can_signal_t> >& signals, bool* send);
static openxc_DynamicField decodeSignal(can_signal_t& signal, const can_message_t& message,
const std::vector<can_signal_t>& signals, bool* send);
diff --git a/CAN-binder/low-can-binding/can/can-message-definition.cpp b/CAN-binder/low-can-binding/can/can-message-definition.cpp
index 3603bf27..18a07bb0 100644
--- a/CAN-binder/low-can-binding/can/can-message-definition.cpp
+++ b/CAN-binder/low-can-binding/can/can-message-definition.cpp
@@ -17,16 +17,16 @@
#include "can-message-definition.hpp"
-can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id, const std::string bus)
- : message_set_id_{message_set_id}, bus_{bus}, last_value_{CAN_MESSAGE_SIZE}
+can_message_definition_t::can_message_definition_t(const std::string bus)
+ : parent_{nullptr}, bus_{bus}, last_value_{CAN_MESSAGE_SIZE}
{}
-can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id,
+can_message_definition_t::can_message_definition_t(
const std::string bus,
uint32_t id,
frequency_clock_t frequency_clock,
bool force_send_changed)
- : message_set_id_{message_set_id},
+ : parent_{nullptr},
bus_{bus},
id_{id},
frequency_clock_{frequency_clock},
@@ -34,13 +34,13 @@ can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id,
last_value_{CAN_MESSAGE_SIZE}
{}
-can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id,
+can_message_definition_t::can_message_definition_t(
const std::string bus,
uint32_t id,
can_message_format_t format,
frequency_clock_t frequency_clock,
bool force_send_changed)
- : message_set_id_{message_set_id},
+ : parent_{nullptr},
bus_{bus},
id_{id},
format_{format},
@@ -49,6 +49,39 @@ can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id,
last_value_{CAN_MESSAGE_SIZE}
{}
+can_message_definition_t::can_message_definition_t(
+ const std::string bus,
+ uint32_t id,
+ can_message_format_t format,
+ frequency_clock_t frequency_clock,
+ bool force_send_changed,
+ std::vector<std::shared_ptr<can_signal_t> > can_signals)
+ : parent_{nullptr},
+ bus_{bus},
+ id_{id},
+ format_{format},
+ frequency_clock_{frequency_clock},
+ force_send_changed_{force_send_changed},
+ last_value_{CAN_MESSAGE_SIZE},
+ can_signals_{std::move(can_signals)}
+{
+ for(auto& sig: can_signals_)
+ {
+ sig->set_parent(std::make_shared<can_signal_t>(this));
+ }
+}
+
+/*can_message_definition_t(const can_message_definition_t& b)
+ : parent_{b.parent_},
+ bus_{b.bus_},
+ id_{b.id_},
+ format_{b.format_},
+ frequency_clock_{b.frequency_clock_},
+ force_send_changed_{b.force_send_changed_},
+ last_value_{b.last_value_},
+ can_signals_{b.can_signals_}
+ {}*/
+
const std::string& can_message_definition_t::get_bus_name() const
{
return bus_;
@@ -57,6 +90,17 @@ const std::string& can_message_definition_t::get_bus_name() const
uint32_t can_message_definition_t::get_id() const
{
return id_;
+}
+
+std::vector<std::shared_ptr<can_signal_t> > can_message_definition_t::get_can_signals()
+{
+ return can_signals_;
+}
+
+void can_message_definition_t::set_parent(std::shared_ptr<can_message_set_t> parent)
+{
+ parent_= parent;
+}
void can_message_definition_t::set_last_value(const can_message_t& cm)
{
diff --git a/CAN-binder/low-can-binding/can/can-message-definition.hpp b/CAN-binder/low-can-binding/can/can-message-definition.hpp
index 42eef89f..612ce357 100644
--- a/CAN-binder/low-can-binding/can/can-message-definition.hpp
+++ b/CAN-binder/low-can-binding/can/can-message-definition.hpp
@@ -29,12 +29,15 @@
#include <memory>
#include "can-message.hpp"
+#include "can-signals.hpp"
#include "../utils/timer.hpp"
+class can_message_set_t;
+
class can_message_definition_t
{
private:
- std::uint8_t message_set_id_;
+ std::shared_ptr<can_message_set_t> parent_; /*!< parent_ - Pointer to the CAN message set holding this CAN message definition */
std::string bus_; /*!< bus_ - Address of CAN bus device. */
uint32_t id_; /*!< id_ - The ID of the message.*/
can_message_format_t format_; /*!< format_ - the format of the message's ID.*/
@@ -46,14 +49,19 @@ private:
std::vector<uint8_t> last_value_; /*!< last_value_ - The last received value of the message. Defaults to undefined.
* This is required for the forceSendChanged functionality, as the stack
* needs to compare an incoming CAN message with the previous frame.*/
+ std::vector<std::shared_ptr<can_signal_t> > can_signals_; /*!< can_signals_ - Vector holding can_signal_t object which share the same arbitration ID */
public:
- can_message_definition_t(std::uint8_t message_set_id, const std::string bus);
- can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed);
- can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed);
+ //can_message_definition_t(const can_message_definition_t& b);
+ can_message_definition_t(const std::string bus);
+ can_message_definition_t(const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed);
+ can_message_definition_t(const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed);
+ can_message_definition_t(const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed, std::vector<std::shared_ptr<can_signal_t> > can_signals);
const std::string& get_bus_name() const;
uint32_t get_id() const;
+ std::vector<std::shared_ptr<can_signal_t> > get_can_signals();
+ void set_parent(std::shared_ptr<can_message_set_t> parent);
void set_last_value(const can_message_t& cm);
};
diff --git a/CAN-binder/low-can-binding/can/can-message-set.cpp b/CAN-binder/low-can-binding/can/can-message-set.cpp
index a9f8cf23..1877f3a2 100644
--- a/CAN-binder/low-can-binding/can/can-message-set.cpp
+++ b/CAN-binder/low-can-binding/can/can-message-set.cpp
@@ -25,7 +25,8 @@ can_message_set_t::can_message_set_t(
unsigned short can_message_count,
unsigned short can_signal_count,
unsigned short can_command_count,
- unsigned short obd2_signal_count)
+ unsigned short obd2_signal_count,
+ std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition)
: index_{index}
, name_{name}
, can_bus_count_{can_bus_count}
@@ -33,5 +34,30 @@ can_message_set_t::can_message_set_t(
, can_signal_count_{can_signal_count}
, can_command_count_{can_command_count}
, obd2_signal_count_{obd2_signal_count}
+ , can_messages_definition_{can_messages_definition}
{
+ for(auto& cmd : can_messages_definition_)
+ {
+ cmd->set_parent(std::make_shared<can_message_set_t>(this));
+ }
}
+
+/// @brief Return vector holding all message definition handled by this message set.
+std::vector<std::shared_ptr<can_message_definition_t> > can_message_set_t::get_can_message_definition()
+{
+ return can_messages_definition_;
+}
+
+std::vector<std::shared_ptr<can_signal_t> > can_message_set_t::get_can_signals() const
+{
+ std::vector<std::shared_ptr<can_signal_t> > can_signals(can_signal_count_);
+ for(const auto& cmd: can_messages_definition_)
+ {
+ can_signals.insert( can_signals.end(),
+ cmd->get_can_signals().begin(),
+ cmd->get_can_signals().end()
+ );
+ }
+
+ return can_signals;
+} \ No newline at end of file
diff --git a/CAN-binder/low-can-binding/can/can-message-set.hpp b/CAN-binder/low-can-binding/can/can-message-set.hpp
index 94e2d8d5..3d917c11 100644
--- a/CAN-binder/low-can-binding/can/can-message-set.hpp
+++ b/CAN-binder/low-can-binding/can/can-message-set.hpp
@@ -20,6 +20,12 @@
#include <cstdint>
#include <string>
+#include <vector>
+#include <memory>
+
+#include "can-message-definition.hpp"
+
+class can_signal_t;
/// @brief A parent wrapper for a particular set of CAN messages and associated
/// CAN buses(e.g. a vehicle or program).
@@ -33,6 +39,7 @@ private:
uint16_t can_signal_count_; /// < The number of CAN signals (across all messages) defined for this message set.
uint16_t can_command_count_; /// < The number of CanCommmands defined for this message set.
uint16_t obd2_signal_count_; /// < The number of obd2 signals defined for this message set.
+ std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition_; ///< Vector holding all message definition handled by this message set.
public:
can_message_set_t(
@@ -42,6 +49,9 @@ public:
short unsigned int can_message_count,
short unsigned int can_signal_count,
short unsigned int can_command_count,
- short unsigned int obd2_signal_count);
+ short unsigned int obd2_signal_count,
+ std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition);
+ std::vector<std::shared_ptr<can_message_definition_t> > get_can_message_definition();
+ std::vector<std::shared_ptr<can_signal_t> > get_can_signals() const;
};
diff --git a/CAN-binder/low-can-binding/can/can-signals.cpp b/CAN-binder/low-can-binding/can/can-signals.cpp
index 7726bfc1..96d0b707 100644
--- a/CAN-binder/low-can-binding/can/can-signals.cpp
+++ b/CAN-binder/low-can-binding/can/can-signals.cpp
@@ -29,8 +29,7 @@
std::string can_signal_t::prefix_ = "messages";
-can_signal_t::can_signal_t(std::uint8_t message_set_id,
- std::uint8_t message_id,
+can_signal_t::can_signal_t(
std::string generic_name,
uint8_t bit_position,
uint8_t bit_size,
@@ -46,9 +45,8 @@ can_signal_t::can_signal_t(std::uint8_t message_set_id,
SignalDecoder decoder,
SignalEncoder encoder,
bool received)
- : message_set_id_{ message_set_id }
- , message_id_{ message_id }
- , generic_name_{ generic_name }
+ : parent_{nullptr},
+ generic_name_{ generic_name }
, bit_position_{ bit_position }
, bit_size_{ bit_size }
, factor_{ factor }
@@ -66,14 +64,34 @@ can_signal_t::can_signal_t(std::uint8_t message_set_id,
, last_value_{.0f}
{}
+/*can_signal_t::can_signal_t(const can_signal_t& b)
+ : parent_{b.parent_},
+ generic_name_{ b.generic_name_}
+ , bit_position_{ b.bit_position_}
+ , bit_size_{ b.bit_size_}
+ , factor_{ b.factor_ }
+ , offset_{ b.offset_}
+ , min_value_{b.min_value_}
+ , max_value_{b.max_value_}
+ , frequency_{b.frequency_}
+ , send_same_{b.send_same_}
+ , force_send_changed_{b.force_send_changed_}
+ , states_{b.states_}
+ , writable_{b.writable_}
+ , decoder_{b.decoder_}
+ , encoder_{b.encoder_}
+ , received_{b.received_}
+ , last_value_{b.last_value_}
+{}*/
+
utils::socketcan_bcm_t can_signal_t::get_socket() const
{
return socket_;
}
-can_message_definition_t& can_signal_t::get_message() const
+std::shared_ptr<can_message_definition_t> can_signal_t::get_message() const
{
- return configuration_t::instance().get_can_message_definition(message_set_id_, message_id_);
+ return parent_;
}
const std::string& can_signal_t::get_generic_name() const
@@ -177,6 +195,11 @@ float can_signal_t::get_last_value() const
return last_value_;
}
+void can_signal_t::set_parent(std::shared_ptr<can_message_definition_t> parent)
+{
+ parent_(parent);
+}
+
void can_signal_t::set_prefix(std::string val)
{
prefix_ = val;
diff --git a/CAN-binder/low-can-binding/can/can-signals.hpp b/CAN-binder/low-can-binding/can/can-signals.hpp
index 75faedf0..6497a3c6 100644
--- a/CAN-binder/low-can-binding/can/can-signals.hpp
+++ b/CAN-binder/low-can-binding/can/can-signals.hpp
@@ -19,15 +19,14 @@
#include <map>
#include <mutex>
-#include <queue>
#include <vector>
#include <string>
+#include <memory>
#include "openxc.pb.h"
#include "../utils/timer.hpp"
#include "../utils/socketcan-bcm.hpp"
#include "can-message.hpp"
-#include "can-message-definition.hpp"
#include "../diagnostic/diagnostic-message.hpp"
extern "C"
@@ -39,6 +38,7 @@ extern "C"
#define MESSAGE_SET_ID 0
class can_signal_t;
+class can_message_definition_t;
///
/// @brief The type signature for a CAN signal decoder.
@@ -76,9 +76,8 @@ typedef uint64_t (*SignalEncoder)(can_signal_t* signal,
class can_signal_t
{
private:
+ std::shared_ptr<can_message_definition_t> parent_; /*!< parent_ - pointer to the parent message definition holding this signal*/
utils::socketcan_bcm_t socket_; /*!< socket_ - Specific BCM socket that filter the signal read from CAN device */
- std::uint8_t message_set_id_; ///< message_set_id_ - Index number to the message_set_id container object
- std::uint8_t message_id_; ///< message_id_ - Index number to the message_definition_t container object
std::string generic_name_; /*!< generic_name_ - The name of the signal to be output.*/
static std::string prefix_; /*!< prefix_ - generic_name_ will be prefixed with it. It has to reflect the used protocol.
* which make easier to sort message when the come in.*/
@@ -112,9 +111,8 @@ private:
* this value is undefined. */
public:
+ //can_signal_t(const can_signal_t& b);
can_signal_t(
- std::uint8_t message_set_id,
- std::uint8_t message_id,
std::string generic_name,
uint8_t bit_position,
uint8_t bit_size,
@@ -132,7 +130,7 @@ public:
bool received);
utils::socketcan_bcm_t get_socket() const;
- can_message_definition_t& get_message() const;
+ std::shared_ptr<can_message_definition_t> get_message() const;
const std::string& get_generic_name() const;
const std::string get_name() const;
const std::string& get_prefix() const;
@@ -154,6 +152,7 @@ public:
bool get_received() const;
float get_last_value() const;
+ void set_parent(std::shared_ptr<can_message_definition_t> parent);
void set_prefix(std::string val);
void set_received(bool r);
void set_last_value(float val);