2 * Copyright (C) 2015, 2016 "IoT.bzh"
3 * Author "Romain Forlot" <romain.forlot@iot.bzh>
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <linux/can.h>
26 #include "can-utils.hpp"
27 #include "low-can-binding.hpp"
31 #include <afb/afb-event-itf.h>
34 #define MESSAGE_SET_ID 0
36 /** Can signal event map making access to afb_event
37 * external to openxc existing structure.
39 static std::map<std::string, struct afb_event> subscribed_signals;
40 static std::map<std::string, struct afb_event>::iterator subscribed_signals_i;
43 * @brief Dumb SIGNALS array. It is composed by CanMessageSet
44 * SIGNALS[MESSAGE_SET_ID][CanSignal]
46 std::vector<std::vector<CanSignal>> SIGNALS {
47 { // message set: example
51 /** Public: Return the currently active CAN configuration. */
52 CanMessageSet* getActiveMessageSet();
54 /** Public: Retrive a list of all possible CAN configurations.
56 * Returns a pointer to an array of all configurations.
58 CanMessageSet* getMessageSets();
60 /** Public: Return the length of the array returned by getMessageSets() */
61 int getMessageSetCount();
63 /* Public: Return the number of CAN buses configured in the active
64 * configuration. This is limited to 2, as the hardware controller only has 2
69 /* Public: Return an array of all CAN messages to be processed in the active
72 CanMessageDefinition* getMessages();
74 /* Public: Return signals from an signals array filtered on name.
76 CanSignal* getSignals(std::string name);
78 /* Public: Return an array of all OpenXC CAN commands enabled in the active
79 * configuration that can write back to CAN with a custom handler.
81 * * Commands not defined here are handled using a 1-1 mapping from the signals
84 CanCommand* getCommands();
86 /* Public: Return the length of the array returned by getCommandCount(). */
87 int getCommandCount();
89 /* Public: Return the length of the array returned by getSignals(). */
90 size_t getSignalCount();
92 /* Public: Return the length of the array returned by getMessages(). */
93 int getMessageCount();
96 * @brief Return an array of the metadata for the 2 CAN buses you want to
97 * monitor. The size of this array is fixed at 2.
99 CanBus* getCanBuses();
102 * @brief Find one or many signals based on its name or id
103 * passed through openxc_DynamicField.
105 * params[openxc_DynamicField&] - a const reference with the key to search into signal.
106 * Key is either a signal name or its CAN arbitration id.
108 * return[std::vector<std::string>] return found CanSignal generic name vector.
110 std::vector<CanSignal> find_can_signals(const openxc_DynamicField &key);
112 uint32_t get_CanSignal_id(const CanSignal& sig)
114 return sig.message->id;