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.
23 #include "can/can-bus.hpp"
24 #include "can/can-message.hpp"
26 #include "low-can-binding.hpp"
43 * @brief A representation of an OBD-II PID.
45 * pid - The 1 byte PID.
46 * name - A human readable name to use for this PID when published.
47 * min - minimum value for this pid
48 * max - maximum value for this pid
50 * frequency - The frequency to request this PID if supported by the vehicle
51 * when automatic, recurring OBD-II requests are enabled.
52 * supported - is it supported by the vehicle. Initialized after scan
54 typedef struct _Obd2Pid {
56 const char* generic_name;
65 * @brief - Object to handle obd2 session with pre-scan of supported pid
66 * then request them regularly
70 uint8_t pid_; /*!< pid - The 1 byte PID.*/
71 std::string generic_name_; /*!< generic_name_ - A human readable name to use for this PID when published.*/
72 int min_; /*!< min_ - Minimum value that can take this pid */
73 int max_; /*!< max_ - Maximum value that can take this pid */
74 enum UNIT unit_; /*!< unit_ : Which unit system is used by that pid. See enum UNIT above.*/
75 int frequency_; /*!< frequency - The frequency to request this PID if supported by the vehicle when automatic, recurring OBD-II requests are enabled.*/
76 bool supported_; /*!< supported_ - boolean indicating whether this pid is supported by the vehicle or not.*/
79 const char* generic_name = generic_name_.c_str();
80 obd2_signal_t(uint8_t pid, const char* generic_name, const int min_, const int max_, enum UNIT unit, int frequency, bool supported);
84 void add_request(int pid);
87 bool is_obd2_response(can_message_t can_message);
88 bool is_obd2_request(DiagnosticRequest *request);
89 bool is_obd2_signal(const char *name);
91 float decode_obd2_response(const DiagnosticResponse* response, float parsedPayload);