summaryrefslogtreecommitdiffstats
path: root/CAN-binder
diff options
context:
space:
mode:
Diffstat (limited to 'CAN-binder')
-rw-r--r--CAN-binder/low-can-binding/binding/configuration-generated.cpp80
-rw-r--r--CAN-binder/low-can-binding/binding/configuration.cpp6
-rw-r--r--CAN-binder/low-can-binding/binding/configuration.hpp6
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.cpp2
-rw-r--r--CAN-binder/low-can-binding/can/can-decoder.cpp16
-rw-r--r--CAN-binder/low-can-binding/can/can-decoder.hpp14
-rw-r--r--CAN-binder/low-can-binding/can/can-message-definition.cpp2
-rw-r--r--CAN-binder/low-can-binding/can/can-message-set.cpp2
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.cpp6
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.hpp2
-rw-r--r--CAN-binder/low-can-binding/utils/signals.hpp28
11 files changed, 82 insertions, 82 deletions
diff --git a/CAN-binder/low-can-binding/binding/configuration-generated.cpp b/CAN-binder/low-can-binding/binding/configuration-generated.cpp
index 3ab911a9..d4778ba1 100644
--- a/CAN-binder/low-can-binding/binding/configuration-generated.cpp
+++ b/CAN-binder/low-can-binding/binding/configuration-generated.cpp
@@ -104,7 +104,7 @@ configuration_t::configuration_t()
, diagnostic_messages_
{
{
- {
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
4,
"engine.load",
0,
@@ -114,8 +114,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
5,
"engine.coolant.temperature",
0,
@@ -125,8 +125,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
10,
"fuel.pressure",
0,
@@ -136,8 +136,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
11,
"intake.manifold.pressure",
0,
@@ -147,8 +147,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
12,
"engine.speed",
0,
@@ -158,8 +158,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
13,
"vehicle.speed",
0,
@@ -169,8 +169,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
15,
"intake.air.temperature",
0,
@@ -180,8 +180,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
16,
"mass.airflow",
0,
@@ -191,8 +191,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
17,
"throttle.position",
0,
@@ -202,8 +202,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
31,
"running.time",
0,
@@ -213,8 +213,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
45,
"EGR.error",
0,
@@ -224,8 +224,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
47,
"fuel.level",
0,
@@ -235,8 +235,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
51,
"barometric.pressure",
0,
@@ -246,8 +246,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
76,
"commanded.throttle.position",
0,
@@ -257,8 +257,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
82,
"ethanol.fuel.percentage",
0,
@@ -268,8 +268,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
90,
"accelerator.pedal.position",
0,
@@ -279,8 +279,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
91,
"hybrid.battery-pack.remaining.life",
0,
@@ -290,8 +290,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
92,
"engine.oil.temperature",
0,
@@ -301,8 +301,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
94,
"engine.fuel.rate",
0,
@@ -312,8 +312,8 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- },
- {
+ })},
+ {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
99,
"engine.torque",
0,
@@ -323,7 +323,7 @@ configuration_t::configuration_t()
decoder_t::decode_obd2_response,
nullptr,
true
- }
+ })}
}
}
{}
diff --git a/CAN-binder/low-can-binding/binding/configuration.cpp b/CAN-binder/low-can-binding/binding/configuration.cpp
index da9d16b2..005e6629 100644
--- a/CAN-binder/low-can-binding/binding/configuration.cpp
+++ b/CAN-binder/low-can-binding/binding/configuration.cpp
@@ -57,7 +57,7 @@ std::vector<std::shared_ptr<can_signal_t> > configuration_t::get_can_signals()
return can_message_set_[active_message_set_].get_can_signals();
}
-std::vector<diagnostic_message_t>& configuration_t::get_diagnostic_messages()
+std::vector<std::shared_ptr<diagnostic_message_t> > configuration_t::get_diagnostic_messages()
{
return diagnostic_messages_[active_message_set_];
}
@@ -83,7 +83,7 @@ void configuration_t::set_active_message_set(uint8_t id)
}
-diagnostic_message_t* configuration_t::get_diagnostic_message(std::string message_name) const
+std::shared_ptr<diagnostic_message_t> configuration_t::get_diagnostic_message(std::string message_name) const
{
struct utils::signals_found found;
found = utils::signals_manager_t::instance().find_signals(build_DynamicField(message_name));
@@ -94,7 +94,7 @@ diagnostic_message_t* configuration_t::get_diagnostic_message(std::string messag
DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(std::string message_name) const
{
- diagnostic_message_t* diag_msg = get_diagnostic_message(message_name);
+ std::shared_ptr<diagnostic_message_t> diag_msg = get_diagnostic_message(message_name);
if( diag_msg != nullptr && diag_msg->get_supported())
return new DiagnosticRequest(diag_msg->build_diagnostic_request());
return nullptr;
diff --git a/CAN-binder/low-can-binding/binding/configuration.hpp b/CAN-binder/low-can-binding/binding/configuration.hpp
index 44881645..2f1f4fce 100644
--- a/CAN-binder/low-can-binding/binding/configuration.hpp
+++ b/CAN-binder/low-can-binding/binding/configuration.hpp
@@ -50,7 +50,7 @@ class configuration_t
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<diagnostic_message_t>> diagnostic_messages_; ///< Vector of vector holding all diagnostics messages from JSON signals description file. First vector map to message set
+ std::vector<std::vector<std::shared_ptr<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.
@@ -71,7 +71,7 @@ class configuration_t
std::vector<std::shared_ptr<can_signal_t> > get_can_signals();
- std::vector<diagnostic_message_t>& get_diagnostic_messages();
+ std::vector<std::shared_ptr<diagnostic_message_t> > get_diagnostic_messages();
const std::vector<std::string>& get_signals_prefix() const;
@@ -83,7 +83,7 @@ class configuration_t
void set_active_message_set(uint8_t id);
- diagnostic_message_t* get_diagnostic_message(std::string message_name) const;
+ std::shared_ptr<diagnostic_message_t> get_diagnostic_message(std::string message_name) const;
DiagnosticRequest* get_request_from_diagnostic_message(std::string message_name) const;
/*
/// TODO: implement this function as method into can_bus class
diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.cpp b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
index 21838936..eaa4fabc 100644
--- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp
+++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
@@ -189,7 +189,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe,
return -1;
}
struct sd_event_source* e_source;
- sd_event_add_io(afb_daemon_get_event_loop(binder_interface->daemon), &e_source, sig->get_socket().socket(), EPOLLIN, read, sig);
+ sd_event_add_io(afb_daemon_get_event_loop(binder_interface->daemon), &e_source, sig->get_socket().socket(), EPOLLIN, read, sig.get());
rets++;
DEBUG(binder_interface, "%s: signal: %s subscribed", __FUNCTION__, sig->get_name().c_str());
}
diff --git a/CAN-binder/low-can-binding/can/can-decoder.cpp b/CAN-binder/low-can-binding/can/can-decoder.cpp
index 419eac1b..eae4ef25 100644
--- a/CAN-binder/low-can-binding/can/can-decoder.cpp
+++ b/CAN-binder/low-can-binding/can/can-decoder.cpp
@@ -54,7 +54,7 @@ float decoder_t::parseSignalBitfield(can_signal_t& signal, const can_message_t&
/// always succeeds.
///
openxc_DynamicField decoder_t::noopDecoder(can_signal_t& signal,
- const std::vector<can_signal_t>& signals, float value, bool* send)
+ const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send)
{
openxc_DynamicField decoded_value = build_DynamicField(value);
@@ -76,7 +76,7 @@ openxc_DynamicField decoder_t::noopDecoder(can_signal_t& signal,
/// decoder always succeeds.
///
openxc_DynamicField decoder_t::booleanDecoder(can_signal_t& signal,
- const std::vector<can_signal_t>& signals, float value, bool* send)
+ const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send)
{
openxc_DynamicField decoded_value = build_DynamicField(value == 0.0 ? false : true);
@@ -98,7 +98,7 @@ openxc_DynamicField decoder_t::booleanDecoder(can_signal_t& signal,
/// @return Return value is undefined.
///
openxc_DynamicField decoder_t::ignoreDecoder(can_signal_t& signal,
- const std::vector<can_signal_t>& signals, float value, bool* send)
+ const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send)
{
if(send)
*send = false;
@@ -125,7 +125,7 @@ openxc_DynamicField decoder_t::ignoreDecoder(can_signal_t& signal,
/// return value is undefined.
///
openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal,
- const std::vector<can_signal_t>& signals, float value, bool* send)
+ const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send)
{
const std::string signal_state = signal.get_states((uint8_t)value);
openxc_DynamicField decoded_value = build_DynamicField(signal_state);
@@ -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<std::shared_ptr<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);
@@ -172,7 +172,7 @@ openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_m
*send = false;
}
signal.set_last_value(value);
- signal.get_message().set_last_value(message);
+ signal.get_message()->set_last_value(message);
return decoded_value;
}
@@ -192,7 +192,7 @@ openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_m
/// string or boolean. If 'send' is false, the return value is undefined.
///
openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal,
- float value, const std::vector<can_signal_t>& signals, bool* send)
+ float value, const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send)
{
SignalDecoder decoder = signal.get_decoder() == nullptr ?
noopDecoder : signal.get_decoder();
@@ -215,7 +215,7 @@ openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal,
/// not be decoded.
///
openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal,
- const can_message_t& message, const std::vector<can_signal_t>& signals, bool* send)
+ const can_message_t& message, const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send)
{
float value = parseSignalBitfield(signal, message);
return decodeSignal(signal, value, signals, send);
diff --git a/CAN-binder/low-can-binding/can/can-decoder.hpp b/CAN-binder/low-can-binding/can/can-decoder.hpp
index 1e7efc6b..238bfeae 100644
--- a/CAN-binder/low-can-binding/can/can-decoder.hpp
+++ b/CAN-binder/low-can-binding/can/can-decoder.hpp
@@ -26,23 +26,23 @@ class decoder_t
public:
static float parseSignalBitfield(can_signal_t& signal, const can_message_t& message);
- static openxc_DynamicField stateDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals,
+ static openxc_DynamicField stateDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals,
float value, bool* send);
- static openxc_DynamicField booleanDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals,
+ static openxc_DynamicField booleanDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals,
float value, bool* send);
- static openxc_DynamicField ignoreDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals,
+ static openxc_DynamicField ignoreDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals,
float value, bool* send);
- static openxc_DynamicField noopDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals,
+ static openxc_DynamicField noopDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals,
float value, bool* send);
static openxc_DynamicField translateSignal(can_signal_t& signal, const can_message_t& message,
- const std::vector<std::shared_ptr<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);
+ const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send);
static openxc_DynamicField decodeSignal(can_signal_t& signal, float value,
- const std::vector<can_signal_t>& signals, bool* send);
+ const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send);
static float decode_obd2_response(const DiagnosticResponse* response, float parsed_payload);
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 18a07bb0..e947026b 100644
--- a/CAN-binder/low-can-binding/can/can-message-definition.cpp
+++ b/CAN-binder/low-can-binding/can/can-message-definition.cpp
@@ -67,7 +67,7 @@ can_message_definition_t::can_message_definition_t(
{
for(auto& sig: can_signals_)
{
- sig->set_parent(std::make_shared<can_signal_t>(this));
+ sig->set_parent(std::make_shared<can_message_definition_t>(*this));
}
}
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 1877f3a2..7ee2a017 100644
--- a/CAN-binder/low-can-binding/can/can-message-set.cpp
+++ b/CAN-binder/low-can-binding/can/can-message-set.cpp
@@ -38,7 +38,7 @@ can_message_set_t::can_message_set_t(
{
for(auto& cmd : can_messages_definition_)
{
- cmd->set_parent(std::make_shared<can_message_set_t>(this));
+ cmd->set_parent(std::make_shared<can_message_set_t>(*this));
}
}
diff --git a/CAN-binder/low-can-binding/can/can-signals.cpp b/CAN-binder/low-can-binding/can/can-signals.cpp
index 96d0b707..04d328bf 100644
--- a/CAN-binder/low-can-binding/can/can-signals.cpp
+++ b/CAN-binder/low-can-binding/can/can-signals.cpp
@@ -197,7 +197,7 @@ float can_signal_t::get_last_value() const
void can_signal_t::set_parent(std::shared_ptr<can_message_definition_t> parent)
{
- parent_(parent);
+ parent_ = parent;
}
void can_signal_t::set_prefix(std::string val)
@@ -223,9 +223,9 @@ int can_signal_t::create_rx_filter()
// Make sure that socket has been opened.
if(! socket_)
socket_.open(
- get_message().get_bus_name());
+ get_message()->get_bus_name());
- uint32_t can_id = get_message().get_id();
+ uint32_t can_id = get_message()->get_id();
struct utils::simple_bcm_msg bcm_msg;
struct can_frame cfd;
diff --git a/CAN-binder/low-can-binding/can/can-signals.hpp b/CAN-binder/low-can-binding/can/can-signals.hpp
index 6497a3c6..4b726c35 100644
--- a/CAN-binder/low-can-binding/can/can-signals.hpp
+++ b/CAN-binder/low-can-binding/can/can-signals.hpp
@@ -57,7 +57,7 @@ class can_message_definition_t;
/// @return a decoded value in an openxc_DynamicField struct.
///
typedef openxc_DynamicField (*SignalDecoder)(can_signal_t& signal,
- const std::vector<can_signal_t>& signals, float value, bool* send);
+ const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send);
///
/// @brief: The type signature for a CAN signal encoder.
diff --git a/CAN-binder/low-can-binding/utils/signals.hpp b/CAN-binder/low-can-binding/utils/signals.hpp
index 053433ae..95fd692f 100644
--- a/CAN-binder/low-can-binding/utils/signals.hpp
+++ b/CAN-binder/low-can-binding/utils/signals.hpp
@@ -32,8 +32,8 @@ namespace utils
{
struct signals_found
{
- std::vector<can_signal_t*> can_signals;
- std::vector<diagnostic_message_t*> diagnostic_messages;
+ std::vector<std::shared_ptr<can_signal_t> > can_signals;
+ std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
};
class signals_manager_t
@@ -51,29 +51,29 @@ namespace utils
std::map<std::string, struct afb_event>& get_subscribed_signals();
struct signals_found find_signals(const openxc_DynamicField &key);
- void find_diagnostic_messages(const openxc_DynamicField &key, std::vector<diagnostic_message_t*>& found_signals);
- void find_can_signals(const openxc_DynamicField &key, std::vector<can_signal_t*>& found_signals);
+ void find_diagnostic_messages(const openxc_DynamicField &key, std::vector<std::shared_ptr<diagnostic_message_t> >& found_signals);
+ void find_can_signals(const openxc_DynamicField &key, std::vector<std::shared_ptr<can_signal_t> >& found_signals);
template <typename T>
- void lookup_signals_by_name(const std::string& key, std::vector<T>& signals, std::vector<T*>& found_signals)
+ void lookup_signals_by_name(const std::string& key, std::vector<std::shared_ptr<T> > signals, std::vector<std::shared_ptr<T> > found_signals)
{
- for(T& s : signals)
+ for(std::shared_ptr<T> s : signals)
{
- if(::fnmatch(key.c_str(), s.get_generic_name().c_str(), FNM_CASEFOLD) == 0)
- found_signals.push_back(&s);
- else if(::fnmatch(key.c_str(), s.get_name().c_str(), FNM_CASEFOLD) == 0)
- found_signals.push_back(&s);
+ if(::fnmatch(key.c_str(), s->get_generic_name().c_str(), FNM_CASEFOLD) == 0)
+ found_signals.push_back(s);
+ else if(::fnmatch(key.c_str(), s->get_name().c_str(), FNM_CASEFOLD) == 0)
+ found_signals.push_back(s);
}
}
template <typename T>
- void lookup_signals_by_id(const double key, std::vector<T>& signals, std::vector<T*>& found_signals)
+ void lookup_signals_by_id(const double key, std::vector<std::shared_ptr<T> > signals, std::vector<std::shared_ptr<T> > found_signals)
{
- for(T& s : signals)
+ for(std::shared_ptr<T> s : signals)
{
- if(configuration_t::instance().get_signal_id(s) == key)
+ if(configuration_t::instance().get_signal_id(*s) == key)
{
- found_signals.push_back(&s);
+ found_signals.push_back(s);
}
}
}