diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-03-13 23:07:33 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-03-16 17:15:55 +0100 |
commit | 63d31e29e366fb9dd85debc897fdbc91d9cb2e42 (patch) | |
tree | 3218c15604ce2e7ec0ceba56368e273512f664da | |
parent | a0e0cb5ac95e779cd2746d8c1f0740e141bbcc41 (diff) |
Search into generic_name as well as name + prefix, but
always register generic_name into subscribed_signals.
It will be the output on event and make easier to find
the subscribed signals into the map without prefix.
Change-Id: Iaf0060bedb54003b0c77121afd2bd35d832dba25
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | src/can/can-bus.cpp | 2 | ||||
-rw-r--r-- | src/configuration-generated.cpp | 4 | ||||
-rw-r--r-- | src/utils/signals.hpp | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/can/can-bus.cpp b/src/can/can-bus.cpp index dfecea9..ebfd7ce 100644 --- a/src/can/can-bus.cpp +++ b/src/can/can-bus.cpp @@ -74,7 +74,7 @@ int can_bus_t::process_can_signals(can_message_t& can_message) DEBUG(binder_interface, "Operator[] key string: %s, event valid? %d", sig.generic_name, afb_event_is_valid(s[std::string(sig.generic_name)])); DEBUG(binder_interface, "Nb elt matched char: %d", (int)s.count(sig.generic_name)); DEBUG(binder_interface, "Nb elt matched string: %d", (int)s.count(std::string(sig.generic_name)));*/ - if( s.find(sig->get_name()) != s.end() && afb_event_is_valid(s[sig->get_name()])) + if( s.find(sig->get_generic_name()) != s.end() && afb_event_is_valid(s[sig->get_generic_name()])) { decoded_message = decoder_t::translateSignal(*sig, can_message, configuration_t::instance().get_can_signals()); diff --git a/src/configuration-generated.cpp b/src/configuration-generated.cpp index 26d6564..be3bc36 100644 --- a/src/configuration-generated.cpp +++ b/src/configuration-generated.cpp @@ -52,8 +52,8 @@ std::vector<std::vector<can_message_definition_t>> CAN_MESSAGES_DEFINITION = { */ std::vector<std::vector<can_signal_t>> SIGNALS = { { - can_signal_t((CAN_MESSAGES_DEFINITION[MESSAGE_SET_ID][0]), "can.driver_door.open", 2, 4, 1.000000, 0.000000, 0.000000, 0.000000, frequency_clock_t(), false, true, std::map<int, std::string>(), false, decoder_t::booleanDecoder, nullptr, false), - can_signal_t((CAN_MESSAGES_DEFINITION[MESSAGE_SET_ID][1]), "can.driver_door.close", 0, 4, 1.000000, 0.000000, 0.000000, 0.000000, frequency_clock_t(), false, true, std::map<int, std::string>(),false, decoder_t::booleanDecoder, nullptr, false) + can_signal_t((CAN_MESSAGES_DEFINITION[MESSAGE_SET_ID][0]), "driver_door.open", 2, 4, 1.000000, 0.000000, 0.000000, 0.000000, frequency_clock_t(), false, true, std::vector<std::string>(), false, decoder_t::booleanDecoder, nullptr, false), + can_signal_t((CAN_MESSAGES_DEFINITION[MESSAGE_SET_ID][1]), "driver_door.close", 0, 4, 1.000000, 0.000000, 0.000000, 0.000000, frequency_clock_t(), false, true, std::vector<std::string>(),false, decoder_t::booleanDecoder, nullptr, false) }, }; diff --git a/src/utils/signals.hpp b/src/utils/signals.hpp index 4675b1f..00b9e3e 100644 --- a/src/utils/signals.hpp +++ b/src/utils/signals.hpp @@ -46,6 +46,8 @@ void lookup_signals_by_name(const std::string& key, std::vector<T>& signals, std { if(::fnmatch(key.c_str(), s.get_generic_name().c_str(), FNM_CASEFOLD) == 0) found_signals.push_back(&s); + if(::fnmatch(key.c_str(), s.get_name().c_str(), FNM_CASEFOLD) == 0) + found_signals.push_back(&s); } } @@ -55,7 +57,9 @@ void lookup_signals_by_name(const std::string& key, std::vector<T>& signals, std for(T& s : signals) { if(::fnmatch(key.c_str(), s.get_generic_name().c_str(), FNM_CASEFOLD) == 0) - found_signals_name.push_back(s.get_name()); + found_signals_name.push_back(s.get_generic_name()); + if(::fnmatch(key.c_str(), s.get_name().c_str(), FNM_CASEFOLD) == 0) + found_signals_name.push_back(s.get_generic_name()); } } |