Fix permission label
[apps/agl-service-can-low-level.git] / low-can-binding / can / can-bus-device.hpp
1 /*
2  * Copyright (C) 2015, 2016, 2017 "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 "can-message.hpp"
30 #include "../utils/config-parser.hpp"
31 #include "../binding/low-can-hat.hpp"
32 #include "../binding/low-can-subscription.hpp"
33
34 /// @brief A container for a CAN module paried with a certain bus.
35 ///
36 /// There are three things that control the operating mode of the CAN controller:
37 ///
38 /// - Should arbitrary CAN message writes be allowed? See rawWritable.
39 /// - Should translated, simple vehicle message writes be allowed? See the
40 ///   'writable' field in signals defined for this bus.
41 ///
42 class can_bus_t
43 {
44 private:
45         int index;
46         std::string name;
47         std::string device_name;
48         float max_message_frequency;    //<! maxMessageFrequency - the default maximum frequency for all CAN messages when
49                                                                         /// using the raw passthrough mode. To put no limit on the frequency, set
50                                                                         /// this to 0.
51         bool raw_writable;  //<! rawWritable - True if this CAN bus connection should allow raw CAN messages
52                                                 /// writes. This is independent from the CanSignal 'writable' option, which
53                                                 /// can be set to still allow translated writes back to this bus.
54         bool passthrough_can_messages; //<! passthroughCanMessages - True if low-level CAN messages should be send to the
55                                                                    /// output interface, not just signals as simple vehicle messages.
56
57 public:
58         int get_index() const;
59         const std::string get_bus_name() const;
60         const std::string get_bus_device_name() const;
61         const float max_message_frequency() const;
62         bool get_raw_writable() const;
63         bool get_passthrough_can_messages() const;
64
65 };