all: Copyright update
[apps/agl-service-can-low-level.git] / low-can-binding / can / can-bus-device.hpp
1 /*
2  * Copyright (C) 2015, 2016, 2017, 2018, 2019 "IoT\.bzh"
3  * Author "Romain Forlot" <romain.forlot@iot.bzh>
4  * Author "Loïc Collignon" <loic.collignon@iot.bzh>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *       http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #pragma once
20
21 #include <utility>
22 #include <mutex>
23 #include <queue>
24 #include <thread>
25 #include <linux/can.h>
26 #include <condition_variable>
27
28 #include "openxc.pb.h"
29 #include "message/can-message.hpp"
30 #include "../utils/config-parser.hpp"
31 #include "../binding/low-can-subscription.hpp"
32
33 /// @brief A container for a CAN module paried with a certain bus.
34 ///
35 /// There are three things that control the operating mode of the CAN controller:
36 ///
37 /// - Should arbitrary CAN message writes be allowed? See rawWritable.
38 /// - Should translated, simple vehicle message writes be allowed? See the
39 ///   'writable' field in signals defined for this bus.
40 ///
41 class can_bus_t
42 {
43 private:
44         int index;
45         std::string name;
46         std::string device_name;
47         float max_message_frequency;    //<! maxMessageFrequency - the default maximum frequency for all CAN messages when
48                                                                         /// using the raw passthrough mode. To disable frequency limit, set
49                                                                         /// this to 0.
50         bool raw_writable;  //<! rawWritable - Set to True if the CAN bus connection should allow raw CAN messages
51                                                 /// writes. This is independent from the CanSignal 'writable' option, which
52                                                 /// can also be set to allow translated writes back to this bus.
53         bool passthrough_can_messages; //<! passthroughCanMessages - Set to True if low-level CAN messages should be able to send to the
54                                                                    /// output interface, not just signals as simple vehicle messages.
55
56 public:
57         int get_index() const;
58         const std::string get_bus_name() const;
59         const std::string get_bus_device_name() const;
60         const float max_message_frequency() const;
61         bool get_raw_writable() const;
62         bool get_passthrough_can_messages() const;
63
64 };