1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include "canbus_config.pb.h"
19 
20 #include <android/hardware/automotive/can/1.0/ICanController.h>
21 
22 namespace android::hardware::automotive::can::config {
23 
24 /**
25  * This reads the protobuf config file into a protobuf object. Both text based protobuf files as
26  * well as binary format protobuf files are supported.
27  *
28  * \param filepath string containing the name of the config file to read.
29  * \return a CanBusConfig protobuf object constructed from the config file.
30  */
31 std::optional<CanBusConfig> parseConfigFile(const std::string& filepath);
32 
33 /**
34  * Converts protobuf format single-bus config object to a HAL bus config object.
35  *
36  * \param pb_bus is the protobuf object representing a the configuration of one CAN bus.
37  * \return a converted HAL bus config object.
38  */
39 std::optional<V1_0::ICanController::BusConfig> fromPbBus(const Bus& pb_bus);
40 
41 /**
42  * Get the CAN HAL interface type specified by a given protobuf config object.
43  *
44  * \param pb_bus is the protobuf object representing a the configuration of one CAN bus.
45  * \return the CAN HAL interface type.
46  */
47 std::optional<V1_0::ICanController::InterfaceType> getHalIftype(const Bus& pb_bus);
48 
49 }  // namespace android::hardware::automotive::can::config
50