aboutsummaryrefslogtreecommitdiffstats
path: root/src/can-signals.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-20 09:50:32 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-21 10:59:19 +0000
commitc8a9ae83b95b3105717c58e390ba216567937772 (patch)
tree3bd5d543166474858b11f3039f140de20242bd3a /src/can-signals.cpp
parent15250b2e51e8383a0df4b6e5a870c07e914d406d (diff)
Fix: OBD2_PIDS array initialization
Change-Id: Ic2c297e4ff94a13872f066ca42ee42beb45451ca Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can-signals.cpp')
-rw-r--r--src/can-signals.cpp70
1 files changed, 39 insertions, 31 deletions
diff --git a/src/can-signals.cpp b/src/can-signals.cpp
index b2996933..c6a8ae9e 100644
--- a/src/can-signals.cpp
+++ b/src/can-signals.cpp
@@ -15,57 +15,65 @@
* limitations under the License.
*/
-#include <string>
-#include <vector>
-#include <fnmatch.h>
-#include "can-signals.h"
+#include "can-signals.hpp"
-/* Can signal event map making access to afb_event
- * external to openxc existing structure.
- */
-std::map <CanSignal, struct afb_event> subscribed_signals;
-std::map <CanSignal, struct afb_event>::iterator subscribed_signals_i;
+const std::vector<CanSignal> getSignals()
+{
+ return SIGNALS[MESSAGE_SET_ID];
+}
-#define MESSAGE_SET_ID 0
-std::vector <CanSignal> find_can_signals(openxc_DynamicField &key)
+size_t getSignalCount()
{
- std::vector <CanSignal> signals;
- int n_signals, i;
+ return SIGNALS[MESSAGE_SET_ID].size();
+}
- n_signals = getSignalCount();
+std::vector<CanSignal> find_can_signals(openxc_DynamicField& key)
+{
+ std::vector<CanSignal> signals;
- switch(key->type):
+ switch(key.type)
{
case openxc_DynamicField_Type::openxc_DynamicField_Type_STRING:
- for(const CanSignal& s : SIGNALS[MESSAGE_SET_ID])
+ for(const CanSignal& s : getSignals())
{
- if(fnmatch(key->string_value, s.genericName) == 0)
+ if(fnmatch(key.string_value, s.genericName, FNM_CASEFOLD) == 0)
signals.push_back(s);
}
break;
case openxc_DynamicField_Type::openxc_DynamicField_Type_NUM:
- for(const CanSignal& s : SIGNALS[MESSAGE_SET_ID])
+ for(const CanSignal& s : getSignals())
{
CanMessageDefinition *msg_def = s.message;
- if(msg_def->id == key->numeric_value)
- signals.push_back(s)
+ if(msg_def->id == key.numeric_value)
+ signals.push_back(s);
}
break;
default:
ERROR(interface, "find_can_signals: wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.");
- return NULL;
+ CanSignal cs;
+ ::memset(&cs, 0, sizeof(CanSignal));
+ signals.push_back(cs);
+ return signals;
break;
}
-
return signals;
}
-std::vector<CanSignal>& getSignals()
-{
- return SIGNALS[MESSAGE_SET_ID];
-}
-
-int getSignalCount()
-{
- return SIGNALS[MESSAGE_SET_ID].size();
-} \ No newline at end of file
+ struct CanMessageDefinition* message;
+ const char* genericName;
+ uint8_t bitPosition;
+ uint8_t bitSize;
+ float factor;
+ float offset;
+ float minValue;
+ float maxValue;
+ FrequencyClock frequencyClock;
+ bool sendSame;
+ bool forceSendChanged;
+ const CanSignalState* states;
+ uint8_t stateCount;
+ bool writable;
+ SignalDecoder decoder;
+ SignalEncoder encoder;
+ bool received;
+ float lastValue; \ No newline at end of file