aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-01 09:43:43 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-01 18:40:05 +0200
commit80740ea1082b3034fa5003b812e063063a873d7c (patch)
treee11d9e0b23a930ae591372de9248d68416100542
parent07cf0fca41024a41ba035f6e817a9590b686a992 (diff)
Fix: get signal name no matter type of signal.
One method to return name depending upon which type it is, can or diagnostic. Change-Id: I1e96f88654e14316d3afe527fa6fa0d8ddbf410d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.cpp21
-rw-r--r--CAN-binder/low-can-binding/binding/low-can-cb.hpp6
-rw-r--r--CAN-binder/low-can-binding/can/can-bus.cpp6
3 files changed, 19 insertions, 14 deletions
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 eed0d76..297c377 100644
--- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp
+++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp
@@ -59,8 +59,8 @@ low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filte
: event_filter_{event_filter}
{}
-low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<diagnostic_message_t> diagnostic_message)
- : event_filter_{event_filter}, diagnostic_message_{diagnostic_message}
+low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<active_diagnostic_request_t> active_diagnostic_request)
+ : active_diagnostic_request_{active_diagnostic_request}, event_filter_{event_filter}
{}
low_can_subscription_t::low_can_subscription_t( low_can_subscription_t&& s)
@@ -90,9 +90,14 @@ const std::shared_ptr<can_signal_t> low_can_subscription_t::get_can_signal() con
return can_signal_;
}
-const std::string low_can_subscription_t::get_sig_name() const
+const std::string low_can_subscription_t::get_name() const
{
- return can_signal_->get_name();
+ if (can_signal_ != nullptr)
+ return can_signal_->get_name();
+ if (active_diagnostic_request_ != nullptr)
+ return active_diagnostic_request_->get_name() ;
+
+ return "";
}
float low_can_subscription_t::get_frequency() const
@@ -241,7 +246,7 @@ int read_message(sd_event_source *s, int fd, uint32_t revents, void *userdata)
{
can_subscription->get_socket().close();
can_subscription->create_rx_filter();
- NOTICE(binder_interface, "%s: Recreated RX_SETUP BCM job for can_subscription: %s", __FUNCTION__, can_subscription->get_sig_name().c_str());
+ NOTICE(binder_interface, "%s: Recreated RX_SETUP BCM job for can_subscription: %s", __FUNCTION__, can_subscription->get_name().c_str());
}
else
{
@@ -266,7 +271,7 @@ static int make_subscription_unsubscription(struct afb_req request, std::shared_
/* Make the subscription or unsubscription to the event */
if (((subscribe ? afb_req_subscribe : afb_req_unsubscribe)(request, s[can_subscription->get_index()].second)) < 0)
{
- ERROR(binder_interface, "%s: Operation goes wrong for signal: %s", __FUNCTION__, can_subscription->get_sig_name().c_str());
+ ERROR(binder_interface, "%s: Operation goes wrong for signal: %s", __FUNCTION__, can_subscription->get_name().c_str());
return -1;
}
return 0;
@@ -275,11 +280,11 @@ static int make_subscription_unsubscription(struct afb_req request, std::shared_
static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subscription, std::map<int, std::pair<std::shared_ptr<low_can_subscription_t>, struct afb_event> >& s)
{
int sub_index = can_subscription->get_index();
- struct afb_event event = afb_daemon_make_event(binder_interface->daemon, can_subscription->get_sig_name().c_str());
+ struct afb_event event = afb_daemon_make_event(binder_interface->daemon, can_subscription->get_name().c_str());
s[sub_index] = std::make_pair(can_subscription, event);
if (!afb_event_is_valid(s[sub_index].second))
{
- ERROR(binder_interface, "%s: Can't create an event for %s, something goes wrong.", __FUNCTION__, can_subscription->get_sig_name().c_str());
+ ERROR(binder_interface, "%s: Can't create an event for %s, something goes wrong.", __FUNCTION__, can_subscription->get_name().c_str());
return -1;
}
return 0;
diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.hpp b/CAN-binder/low-can-binding/binding/low-can-cb.hpp
index e05e251..b74fdb2 100644
--- a/CAN-binder/low-can-binding/binding/low-can-cb.hpp
+++ b/CAN-binder/low-can-binding/binding/low-can-cb.hpp
@@ -40,7 +40,7 @@ private:
/// Signal part
std::shared_ptr<can_signal_t> can_signal_;
- std::shared_ptr<diagnostic_message_t> diagnostic_message_;
+ std::shared_ptr<active_diagnostic_request_t> active_diagnostic_request_;
/// Filtering part
struct event_filter_t event_filter_;
@@ -49,7 +49,7 @@ private:
public:
low_can_subscription_t();
low_can_subscription_t(struct event_filter_t event_filter);
- low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<diagnostic_message_t> sig_name);
+ low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<active_diagnostic_request_t> active_diagnostic_request);
low_can_subscription_t(const low_can_subscription_t& s) = delete;
low_can_subscription_t(low_can_subscription_t&& s);
@@ -58,7 +58,7 @@ public:
int get_index() const;
const std::shared_ptr<can_signal_t> get_can_signal() const;
- const std::string get_sig_name() const;
+ const std::string get_name() const;
float get_frequency() const;
float get_min() const;
float get_max() const;
diff --git a/CAN-binder/low-can-binding/can/can-bus.cpp b/CAN-binder/low-can-binding/can/can-bus.cpp
index 84f828e..65e2acd 100644
--- a/CAN-binder/low-can-binding/can/can-bus.cpp
+++ b/CAN-binder/low-can-binding/can/can-bus.cpp
@@ -83,14 +83,14 @@ void can_bus_t::process_can_signals(const can_message_t& can_message)
{
bool send = true;
decoded_message = decoder_t::translateSignal(*sig->get_can_signal(), can_message, conf.get_all_can_signals(), &send);
- openxc_SimpleMessage s_message = build_SimpleMessage(sig->get_sig_name(), decoded_message);
+ openxc_SimpleMessage s_message = build_SimpleMessage(sig->get_name(), decoded_message);
vehicle_message = build_VehicleMessage(s_message, can_message.get_timestamp());
if(send && apply_filter(vehicle_message, sig))
{
std::lock_guard<std::mutex> decoded_can_message_lock(decoded_can_message_mutex_);
push_new_vehicle_message(subscription_id, vehicle_message);
- DEBUG(binder_interface, "%s: %s CAN signals processed.", __FUNCTION__, sig->get_sig_name().c_str());
+ DEBUG(binder_interface, "%s: %s CAN signals processed.", __FUNCTION__, sig->get_name().c_str());
}
}
}
@@ -122,7 +122,7 @@ void can_bus_t::process_diagnostic_signals(diagnostic_manager_t& manager, const
{
std::lock_guard<std::mutex> decoded_can_message_lock(decoded_can_message_mutex_);
push_new_vehicle_message(subscription_id, vehicle_message);
- DEBUG(binder_interface, "%s: %s CAN signals processed.", __FUNCTION__, s[subscription_id].first->get_diag_name().c_str());
+ DEBUG(binder_interface, "%s: %s CAN signals processed.", __FUNCTION__, s[subscription_id].first->get_name().c_str());
}
}
}