summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-02 22:35:22 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-02 22:35:22 +0100
commit8b642a7d7dbb2bdba0c9e33e746181bcf57b8545 (patch)
treed756005bdae2231bd2c9637a215db8809d536a5a
parente914a50b0bd655de77a6c0225c6ede7cbd0e606f (diff)
Adding DEBUG messages to track error on STL container
Fix: iteration around signal vector. Change-Id: I188cfa8be452ba5268f236b5a8cd1f2bce89058b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--src/can-signals.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/can-signals.cpp b/src/can-signals.cpp
index 5e8818b9..10935ab0 100644
--- a/src/can-signals.cpp
+++ b/src/can-signals.cpp
@@ -80,31 +80,40 @@ size_t getSignalCount()
std::vector<CanSignal> find_can_signals(const openxc_DynamicField &key)
{
- std::vector<CanSignal> signals = {};
+ std::vector<CanSignal> found_signals = {};
+ std::vector<CanSignal> active_signals = getSignals();
+ /* STL container my love ! Welcome to the printf debugging venerable technique !
+ * use those DEBUG message if you need to !
+ DEBUG(binder_interface, "We get %d signal(s) to process", (int)active_signals.size()); */
switch(key.type)
{
case openxc_DynamicField_Type::openxc_DynamicField_Type_STRING:
- for(const CanSignal& s : getSignals())
+ for(const CanSignal& s : active_signals)
{
- if(fnmatch(key.string_value, s.genericName, FNM_CASEFOLD) == 0)
- signals.push_back(s);
+ //DEBUG(binder_interface, "Processing signal: %s", s.genericName);
+ if(::fnmatch(key.string_value, s.genericName, FNM_CASEFOLD) == 0)
+ {
+ //DEBUG(binder_interface, "Matched signal: %s", s.genericName);
+ found_signals.push_back(s);
+ }
}
break;
case openxc_DynamicField_Type::openxc_DynamicField_Type_NUM:
- for(const CanSignal& s : getSignals())
+ for(const CanSignal& s : active_signals)
{
CanMessageDefinition *msg_def = s.message;
if(msg_def->id == key.numeric_value)
- signals.push_back(s);
+ found_signals.push_back(s);
}
break;
default:
ERROR(binder_interface, "find_can_signals: wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.");
- return signals;
+ return found_signals;
break;
}
- return signals;
+ DEBUG(binder_interface, "Found %d signal(s)", (int)found_signals.size());
+ return found_signals;
}
inline uint32_t get_CanSignal_id(const CanSignal& sig)