Cleaning CMAke
[apps/low-level-can-service.git] / CAN-binder / low-can-binding / can / can-command.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 "openxc.pb.h"
21 #include "can-signals.hpp"
22
23 ///
24 /// @brief The type signature for a function to handle a custom OpenXC command.
25 ///
26 /// @param[in] name - the name of the received command.
27 /// @param[in] value - the value of the received command, in a DynamicField. The actual type
28 ///             may be a number, string or bool.
29 /// @param[in] event - an optional event from the received command, in a DynamicField. The
30 ///             actual type may be a number, string or bool.
31 /// @param[in] signals - The list of all signals.
32 /// @param[in] signalCount - The length of the signals array.
33 ///
34 typedef void (*CommandHandler)(const char* name, openxc_DynamicField* value,
35                 openxc_DynamicField* event, can_signal_t* signals, int signalCount);
36
37 /// @struct CanCommand
38 /// @brief The structure to represent a supported custom OpenXC command.
39 ///
40 /// For completely customized CAN commands without a 1-1 mapping between an
41 /// OpenXC message from the host and a CAN signal, you can define the name of the
42 /// command and a custom function to handle it in the VI. An example is
43 /// the "turn_signal_status" command in OpenXC, which has a value of "left" or
44 /// "right". The vehicle may have separate CAN signals for the left and right
45 /// turn signals, so you will need to implement a custom command handler to send
46 /// the correct signals.
47 ///
48 /// Command handlers are also useful if you want to trigger multiple CAN messages
49 /// or signals from a signal OpenXC message.
50 ///
51 typedef struct {
52         const char* generic_name; /*!< generic_name - The name of the command.*/
53         CommandHandler handler; /*!< handler - An function to process the received command's data and perform some
54                                                          *      action.*/
55 } CanCommand;