Fix: decoder_t class decodeSignal method signature
[apps/agl-service-can-low-level.git] / src / can-signals.hpp
1 /*
2  * Copyright (C) 2015, 2016 "IoT.bzh"
3  * Author "Romain Forlot" <romain.forlot@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 #include <queue>
21 #include <string>
22 #include <vector>
23 #include <fnmatch.h>
24 #include <linux/can.h>
25
26 #include "can-utils.hpp"
27 #include "low-can-binding.hpp"
28
29 extern "C"
30 {
31         #include <afb/afb-event-itf.h>
32 }
33
34 /**
35  * @brief Dumb SIGNALS array. It is composed by CanMessageSet
36  * SIGNALS[MESSAGE_SET_ID][CanSignal]
37  */
38 std::vector<std::vector<CanSignal>> SIGNALS {
39         {}// message set: example
40 };
41
42 /** Public: Return the currently active CAN configuration. */
43 CanMessageSet* getActiveMessageSet();
44
45 /** Public: Retrive a list of all possible CAN configurations.
46  *
47  * Returns a pointer to an array of all configurations.
48  */
49 CanMessageSet* getMessageSets();
50
51 /** Public: Return the length of the array returned by getMessageSets() */
52 int getMessageSetCount();
53
54 /* Public: Return the number of CAN buses configured in the active
55  * configuration. This is limited to 2, as the hardware controller only has 2
56  * CAN channels.
57  */
58 int getCanBusCount();
59
60 /* Public: Return an array of all CAN messages to be processed in the active
61  * configuration.
62  */
63 CanMessageDefinition* getMessages();
64
65 /* Public: Return signals from an signals array filtered on name.
66  */
67 const std::vector<CanSignal> getSignals();
68
69 /* Public: Return an array of all OpenXC CAN commands enabled in the active
70  * configuration that can write back to CAN with a custom handler.
71  *
72  * * Commands not defined here are handled using a 1-1 mapping from the signals
73  * list.
74  *              */
75 CanCommand* getCommands();
76
77 /* Public: Return the length of the array returned by getCommandCount(). */
78 int getCommandCount();
79
80 /* Public: Return the length of the array returned by getSignals(). */
81 size_t getSignalCount();
82
83 /* Public: Return the length of the array returned by getMessages(). */
84 int getMessageCount();
85
86 /**
87  * @brief Return an array of the metadata for the 2 CAN buses you want to
88  * monitor. The size of this array is fixed at 2.
89  */
90 CanBus* getCanBuses();
91
92 /**
93  * @brief Find one or many signals based on its name or id
94  * passed through openxc_DynamicField.
95  *
96  * params[openxc_DynamicField&] - a const reference with the key to search into signal.
97  * Key is either a signal name or its CAN arbitration id.
98  *
99  * return[std::vector<std::string>] return found CanSignal generic name vector.
100  */
101 std::vector<CanSignal> find_can_signals(const openxc_DynamicField &key);
102
103 uint32_t get_CanSignal_id(const CanSignal& sig)
104 {
105         return sig.message->id;
106 }