Format
authorRomain Forlot <romain.forlot@iot.bzh>
Mon, 17 Jul 2017 08:59:10 +0000 (10:59 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 21 Jul 2017 10:02:11 +0000 (12:02 +0200)
Change-Id: I036befbfb38b01d046d35a1364c28e0835dcbd41
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
17 files changed:
examples/toyota/configuration-generated.cpp
libs/ini-config/ini-config.cpp
low-can-binding/binding/application.hpp
low-can-binding/binding/low-can-cb.cpp
low-can-binding/binding/low-can-hat.hpp
low-can-binding/can/can-message-set.hpp
low-can-binding/can/can-signals.cpp
low-can-binding/can/can-signals.hpp
low-can-binding/diagnostic/active-diagnostic-request.cpp
low-can-binding/diagnostic/active-diagnostic-request.hpp
low-can-binding/diagnostic/diagnostic-manager.cpp
low-can-binding/utils/openxc-utils.cpp
low-can-binding/utils/signals.cpp
low-can-binding/utils/signals.hpp
low-can-binding/utils/socketcan-bcm.cpp
low-can-binding/utils/socketcan-raw.cpp
low-can-binding/utils/timer.cpp

index 4b9dac4..61149c5 100644 (file)
@@ -18,8 +18,8 @@ application_t::application_t()
                                "doors.coffer.open",
                                88,
                                1,
-                               0.00000f, 
-                               0, 
+                               0.00000f,
+                               0,
                                0,
                                0,
                                frequency_clock_t(0.00000f),
@@ -38,8 +38,8 @@ application_t::application_t()
                                "doors.driver.open",
                                78,
                                1,
-                               0.00000f, 
-                               0, 
+                               0.00000f,
+                               0,
                                0,
                                0,
                                frequency_clock_t(0.00000f),
@@ -58,8 +58,8 @@ application_t::application_t()
                                "doors.passenger.open",
                                79,
                                1,
-                               0.00000f, 
-                               0, 
+                               0.00000f,
+                               0,
                                0,
                                0,
                                frequency_clock_t(0.00000f),
@@ -78,8 +78,8 @@ application_t::application_t()
                                "doors.rearleft.open",
                                86,
                                1,
-                               0.00000f, 
-                               0, 
+                               0.00000f,
+                               0,
                                0,
                                0,
                                frequency_clock_t(0.00000f),
@@ -98,8 +98,8 @@ application_t::application_t()
                                "doors.rearright.open",
                                85,
                                4,
-                               0.00000f, 
-                               0, 
+                               0.00000f,
+                               0,
                                0,
                                0,
                                frequency_clock_t(0.00000f),
index ef3ab25..e429b95 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "ini-config.hpp"
 
-bool starts_with(const std::string& text, const std::string& token) 
+bool starts_with(const std::string& text, const std::string& token)
 {
        if(text.length() < token.length()) return false;
        return (text.compare(0, token.length(), token) == 0);
@@ -62,7 +62,7 @@ ini_config::map ini_config::get_keys(const std::string& section, bool wo_prefix)
 {
        map ret;
        std::string key;
-       
+
        std::string prefix = section + '/';
        for(auto i = config_.begin();
                i != config_.end();
@@ -97,4 +97,4 @@ ini_config::line_type ini_config::qualify(std::string& line)
                }
        }
        return line_type::ignore;
-}
\ No newline at end of file
+}
index fea61a8..e272806 100644 (file)
@@ -33,8 +33,8 @@
 /// @brief Class representing a configuration attached to the binding.
 ///
 /// It regroups all needed objects instance from other class
-///  that will be used along the binding life. It gets a global vision 
-///  on which signals are implemented for that binding. 
+///  that will be used along the binding life. It gets a global vision
+///  on which signals are implemented for that binding.
 ///  Here, it is only the definition of the class with predefined accessors
 ///  methods used in the binding.
 ///
index be2985f..a190b2a 100644 (file)
@@ -182,7 +182,7 @@ static int subscribe_unsubscribe_diagnostic_messages(struct afb_req request, boo
 
                auto it =  std::find_if(s.begin(), s.end(), [&sig](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub){ return (! sub.second->get_diagnostic_message().empty());});
                can_subscription = it != s.end() ?
-                       it->second : 
+                       it->second :
                        std::make_shared<low_can_subscription_t>(low_can_subscription_t(event_filter));
                // If the requested diagnostic message isn't supported by the car then unsubcribe it
                // no matter what we want, worse case will be a fail unsubscription but at least we don't
index eafb9c6..162a8e5 100644 (file)
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #pragma once
 
 #include <cstddef>
index 2a7cb53..bf53c8c 100644 (file)
@@ -27,7 +27,7 @@ class can_signal_t;
 class can_message_definition_t;
 class diagnostic_message_t;
 
-/// @brief A parent wrapper for a particular set of CAN messages and diagnostic messages 
+/// @brief A parent wrapper for a particular set of CAN messages and diagnostic messages
 /// (e.g. a vehicle or program).
 class can_message_set_t
 {
index 45c54cb..a964556 100644 (file)
@@ -107,7 +107,7 @@ float can_signal_t::get_offset() const
 float can_signal_t::get_min_value() const
 {
        return min_value_;
-}      
+}
 
 float can_signal_t::get_max_value() const
 {
index 1b27622..ea8c077 100644 (file)
@@ -56,7 +56,7 @@ typedef openxc_DynamicField (*signal_decoder)(can_signal_t& signal, float value,
 /// A signal_encoder transforms a number, string or boolean into a raw floating
 /// point value that fits in the CAN signal.
 ///
-/// @param[in] signal - The CAN signal to encode. 
+/// @param[in] signal - The CAN signal to encode.
 /// @param[in] value - The dynamic field to encode.
 /// @param[out] send - An output parameter. If the encoding failed or the CAN signal should
 /// not be encoded for some other reason, this will be flipped to false.
index 1ccb2e7..71f5980 100644 (file)
@@ -41,13 +41,13 @@ active_diagnostic_request_t& active_diagnostic_request_t::operator=(const active
                name_ = adr.name_;
                decoder_ = adr.decoder_;
                callback_ = adr.callback_;
-               recurring_ = adr.recurring_; 
+               recurring_ = adr.recurring_;
                wait_for_multiple_responses_ = adr.wait_for_multiple_responses_;
                frequency_clock_ = adr.frequency_clock_;
                timeout_clock_ = adr.timeout_clock_;
                socket_ = adr.socket_;
        }
-       
+
        return *this;
 }
 
index ff503d8..36f9e43 100644 (file)
@@ -67,7 +67,7 @@ private:
        DiagnosticRequestHandle* handle_; ///< handle_ - A handle for the request to keep track of it between
                                                                          ///< sending the frames of the request and receiving all frames of the response.
        std::string name_; ///< name_ - Human readable name, to be used when publishing received responses.
-       static std::string prefix_; ///< prefix_ - It has to reflect the JSON object which it comes from. It makes easier sorting 
+       static std::string prefix_; ///< prefix_ - It has to reflect the JSON object which it comes from. It makes easier sorting
                                                                ///< incoming CAN messages.
        DiagnosticResponseDecoder decoder_; ///< decoder_ - An optional DiagnosticResponseDecoder to parse the payload of responses
                                                                                ///< to this request. If the decoder is NULL, the output will include the raw payload
index 89303f1..8533503 100644 (file)
@@ -41,7 +41,7 @@ diagnostic_manager_t::diagnostic_manager_t()
 ///  to have 1 diagnostic bus which are the first bus declared in the JSON
 ///  description file. Configuration instance will return it.
 ///
-/// this will initialize DiagnosticShims and cancel all active requests 
+/// this will initialize DiagnosticShims and cancel all active requests
 ///  if there are any.
 bool diagnostic_manager_t::initialize()
 {
@@ -80,7 +80,7 @@ void diagnostic_manager_t::reset()
 /// @param[in] data - The data payload for the message. NULL is valid if size is also 0.
 /// @param[in] size - The size of the data payload, in bytes.
 ///
-/// @return true if the CAN message was sent successfully. 
+/// @return true if the CAN message was sent successfully.
 bool diagnostic_manager_t::shims_send(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size)
 {
        diagnostic_manager_t& dm = application_t::instance().get_diagnostic_manager();
@@ -185,7 +185,7 @@ void diagnostic_manager_t::cancel_request(active_diagnostic_request_t* entry)
 }
 
 /// @brief Cleanup a specific request if it isn't running and get complete. As it is almost
-/// impossible to get that state for a recurring request without waiting for that, you can 
+/// impossible to get that state for a recurring request without waiting for that, you can
 /// force the cleaning operation.
 ///
 /// @param[in] entry - the request to clean
@@ -373,7 +373,7 @@ active_diagnostic_request_t* diagnostic_manager_t::add_recurring_request(Diagnos
                        recurring_requests_.push_back(entry);
 
                        entry->set_handle(shims_, request);
-                       start_diagnostic_request(&shims_, entry->get_handle()); 
+                       start_diagnostic_request(&shims_, entry->get_handle());
                }
                else
                {
@@ -440,7 +440,7 @@ openxc_VehicleMessage diagnostic_manager_t::relay_diagnostic_response(active_dia
 }
 
 /// @brief Will take the CAN message and pass it to the receive functions that will process
-/// diagnostic handle for each active diagnostic request then depending on the result we will 
+/// diagnostic handle for each active diagnostic request then depending on the result we will
 /// return pass the diagnostic response to decode it.
 ///
 /// @param[in] entry - A pointer to an active diagnostic request holding a valid diagnostic handle
@@ -494,7 +494,7 @@ openxc_VehicleMessage diagnostic_manager_t::find_and_decode_adr(const can_messag
 }
 
 /// @brief Tell if the CAN message received is a diagnostic response.
-/// Request broadcast ID use 0x7DF and assigned ID goes from 0x7E0 to Ox7E7. That allows up to 8 ECU to respond 
+/// Request broadcast ID use 0x7DF and assigned ID goes from 0x7E0 to Ox7E7. That allows up to 8 ECU to respond
 /// at the same time. The response is the assigned ID + 0x8, so response ID can goes from 0x7E8 to 0x7EF.
 ///
 /// @param[in] cm - CAN message received from the socket.
index f39f418..3b404f0 100644 (file)
@@ -28,7 +28,7 @@
 ///  and put into the DiagnosticResponse of the VehicleMessage.
 /// @param[in] parsed_value - raw parsed value of the payload from CAN message
 ///
-/// @return a vehicle message including simple message that will be convert into 
+/// @return a vehicle message including simple message that will be convert into
 /// a JSON object before being pushed to the subscribers
 ///
 const openxc_VehicleMessage build_VehicleMessage(active_diagnostic_request_t* request, const DiagnosticResponse& response, float parsed_value)
@@ -92,13 +92,13 @@ const openxc_VehicleMessage build_VehicleMessage(active_diagnostic_request_t* re
 /// @param[in] message - simple message to include into openxc_VehicleMessage
 /// @param[in] timestamp - timestamp from ioctl when reading the socket
 ///
-/// @return a vehicle message including simple message that will be convert into 
+/// @return a vehicle message including simple message that will be convert into
 /// a JSON object before being pushed to the subscribers
 ///
 const openxc_VehicleMessage build_VehicleMessage(const openxc_SimpleMessage& message, uint64_t timestamp)
 {
        openxc_VehicleMessage v;
-       
+
        v.has_type = true,
        v.type = openxc_VehicleMessage_Type::openxc_VehicleMessage_Type_SIMPLE;
        v.has_simple_message = true;
@@ -114,13 +114,13 @@ const openxc_VehicleMessage build_VehicleMessage(const openxc_SimpleMessage& mes
 ///
 /// @param[in] message - simple message to include into openxc_VehicleMessage
 ///
-/// @return a vehicle message including simple message that will be convert into 
+/// @return a vehicle message including simple message that will be convert into
 /// a JSON object before being pushed to the subscribers
 ///
 const openxc_VehicleMessage build_VehicleMessage(const openxc_SimpleMessage& message)
 {
        openxc_VehicleMessage v;
-       
+
        v.has_type = true,
        v.type = openxc_VehicleMessage_Type::openxc_VehicleMessage_Type_SIMPLE;
        v.has_simple_message = true;
@@ -162,7 +162,7 @@ bool is_valid(const openxc_VehicleMessage& v)
 /// @brief Build an openxc_SimpleMessage associating a name to an openxc_DynamicField
 ///
 /// @param[in] name - const string reference name to assign to the created SimpleMessage
-///  this will set has_name member to true and assign name to the name member. Maximum size for name is 
+///  this will set has_name member to true and assign name to the name member. Maximum size for name is
 ///  set to 100 char.
 /// @param[in] value - const reference with DynamicField to assign to SimpleMessage
 ///  value.
@@ -216,12 +216,12 @@ const openxc_DynamicField build_DynamicField(const std::string& value)
        openxc_DynamicField d;
        d.has_type = true;
        d.type = openxc_DynamicField_Type_STRING;
-       
+
        d.has_string_value = true;
        d.has_numeric_value = false;
        d.has_boolean_value = false;
        ::strncpy(d.string_value, value.c_str(), 100);
-       
+
        return d;
 }
 
@@ -239,12 +239,12 @@ const openxc_DynamicField build_DynamicField(double value)
        openxc_DynamicField d;
        d.has_type = true;
        d.type = openxc_DynamicField_Type_NUM;
-       
+
        d.has_string_value = false;
        d.has_numeric_value = true;
        d.has_boolean_value = false;
        d.numeric_value = value;
-       
+
        return d;
 }
 
@@ -260,12 +260,12 @@ const openxc_DynamicField build_DynamicField(bool value)
        openxc_DynamicField d;
        d.has_type = true;
        d.type = openxc_DynamicField_Type_BOOL;
-       
+
        d.has_string_value = false;
        d.has_numeric_value = false;
        d.has_boolean_value = true;
        d.boolean_value = value;
-       
+
        return d;
 }
 
@@ -306,7 +306,7 @@ const openxc_SimpleMessage get_simple_message(const openxc_VehicleMessage& v_msg
 {
        if (v_msg.has_simple_message)
                return v_msg.simple_message;
-       
+
        openxc_SimpleMessage s_msg = { false, "", false, build_DynamicField(false), false, build_DynamicField(false)};
        return s_msg;
 }
@@ -331,10 +331,10 @@ void jsonify_DynamicField(const openxc_DynamicField& field, json_object* value)
 ///
 /// @brief Make a JSON object from a SimpleMessage
 ///
-/// @param[in] s_msg - const reference to an openxc_SimpleMessage 
+/// @param[in] s_msg - const reference to an openxc_SimpleMessage
 /// struct to convert into a json object.
 /// @param[out] json - pointer with the DynamicField converted into json object
-/// 
+///
 /// @return True if SimpleMessage has been transformed into json object
 ///  and false if not. In such case, a json object is returned { "error": "error msg"}
 ///
@@ -348,4 +348,4 @@ bool jsonify_simple(const openxc_SimpleMessage& s_msg, json_object* json)
        }
        json_object_object_add(json, "error", json_object_new_string("openxc_SimpleMessage doesn't have name'"));
        return false;
-}
\ No newline at end of file
+}
index 5c08eaa..7011fa5 100644 (file)
@@ -37,7 +37,7 @@ namespace utils
 
        ///
        /// @brief return the subscribed_signals map.
-       /// 
+       ///
        /// @return Map of subscribed signals.
        std::map<int, std::shared_ptr<low_can_subscription_t> >& signals_manager_t::get_subscribed_signals()
        {
@@ -48,10 +48,10 @@ namespace utils
        /// @fn std::vector<std::string> find_signals(const openxc_DynamicField &key)
        /// @brief return signals name found searching through CAN_signals and OBD2 pid
        ///
-       /// @param[in] key : can contain numeric or string value in order to search against 
+       /// @param[in] key : can contain numeric or string value in order to search against
        ///   can signals or obd2 signals name.
        ///
-       /// @return Vector of signals name found. 
+       /// @return Vector of signals name found.
        ///
        struct signals_found signals_manager_t::find_signals(const openxc_DynamicField &key)
        {
index c604b87..ddaf229 100644 (file)
@@ -37,7 +37,7 @@ namespace utils
                std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
        };
 
-       /// @brief Signal manager singleton hold subscription object with attached afb_event and its mutex 
+       /// @brief Signal manager singleton hold subscription object with attached afb_event and its mutex
        /// to read and write it safely.
        /// It can be used to browse CAN signals and Diagnostic messages vectors and find a particular signal to
        /// subscribe to.
index 39b53f5..750e772 100644 (file)
@@ -39,7 +39,7 @@ namespace utils
        int socketcan_bcm_t::open(std::string device_name)
        {
                close();
-               
+
                struct ifreq ifr;
                socket_ = socketcan_t::open(PF_CAN, SOCK_DGRAM, CAN_BCM);
 
index 58b443b..ca892e7 100644 (file)
@@ -36,7 +36,7 @@ namespace utils
        int socketcan_raw_t::open(std::string device_name)
        {
                close();
-               
+
                struct ifreq ifr;
                socket_ = socketcan_t::open(PF_CAN, SOCK_RAW, CAN_RAW);
 
index d21b747..9152a09 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #include <time.h>
-#include <stdlib.h> 
+#include <stdlib.h>
 #include <cmath>
 
 #include "timer.hpp"
@@ -25,7 +25,7 @@ long long int system_time_us()
 {
        struct timespec t_usec;
        long long int timestamp_usec = 0;
-       
+
        if(!::clock_gettime(CLOCK_MONOTONIC, &t_usec))
                timestamp_usec = (t_usec.tv_nsec / 1000ll) + (t_usec.tv_sec* 1000000ll);
        return timestamp_usec;
@@ -35,7 +35,7 @@ long long int system_time_ms()
 {
        struct timespec t_msec;
        long long int timestamp_msec = 0;
-       
+
        if(!::clock_gettime(CLOCK_MONOTONIC, &t_msec))
                timestamp_msec = (t_msec.tv_nsec / 1000000ll) + (t_msec.tv_sec* 1000ll);
        return timestamp_msec;
@@ -45,7 +45,7 @@ long long int system_time_s()
 {
        struct timespec t_sec;
        long long int timestamp_sec = 0;
-       
+
        if(!::clock_gettime(CLOCK_MONOTONIC, &t_sec))
                timestamp_sec = t_sec.tv_sec;
        return timestamp_sec;
@@ -76,7 +76,7 @@ float frequency_clock_t::frequency_to_period() const
        return frequency_ == 0 ? 0 : 1 / frequency_;
 }
 
-/// @brief Return a timeval struct based on the frequency_ member. used to 
+/// @brief Return a timeval struct based on the frequency_ member. used to
 /// specified CAN BCM timers.
 const struct timeval frequency_clock_t::get_timeval_from_period() const
 {