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.
24 #include "../can/can-message-set.hpp"
25 #include "../can/can-message.hpp"
26 #include "active-diagnostic-request.hpp"
42 class can_message_set_t;
45 /// @brief - A representation of an OBD-II PID.
47 class diagnostic_message_t
50 can_message_set_t* parent_; /*!< parent_ - Pointer to the CAN message set holding this diagnostic message */
51 uint8_t pid_; /*!< pid_ - The 1 byte PID.*/
52 std::string generic_name_; /*!< generic_name_ - A human readable name to use for this PID when published.*/
53 int min_; /*!< min_ - Minimum value that can take this pid */
54 int max_; /*!< max_ - Maximum value that can take this pid */
55 enum UNIT unit_; /*!< unit_ : Which unit system is used by that pid. See enum UNIT above.*/
56 float frequency_; /*!< frequency_ - The frequency to request this PID if supported by the vehicle when automatic, recurring OBD-II requests are enabled.*/
57 DiagnosticResponseDecoder decoder_; /*!< decoder_ - An optional DiagnosticResponseDecoder to parse the payload of responses
58 * to this request. If the decoder is NULL, the output will include the raw payload
59 * instead of a parsed value.*/
60 DiagnosticResponseCallback callback_; /*!< callback_ - An optional DiagnosticResponseCallback to be notified whenever a
61 * response is received for this request.*/
63 bool supported_; /*!< supported_ - boolean indicating whether this pid is supported by the vehicle or not.*/
66 const char* generic_name = generic_name_.c_str();
67 diagnostic_message_t(uint8_t pid, const std::string generic_name, const int min, const int max, enum UNIT unit, float frequency,
68 DiagnosticResponseDecoder decoder, DiagnosticResponseCallback callback, bool supported);
71 const std::string get_generic_name() const;
72 const std::string get_name() const;
73 float get_frequency() const;
74 DiagnosticResponseDecoder get_decoder() const;
75 DiagnosticResponseCallback get_callback() const;
76 bool get_supported() const;
78 void set_supported(bool value);
79 void set_parent(can_message_set_t* parent);
80 const DiagnosticRequest build_diagnostic_request();
82 bool is_obd2_response(const can_message_t& can_message);
83 bool is_obd2_request(const DiagnosticRequest *request);