Cleaning the code for now unused functions 51/18751/3
authorRomain Forlot <romain.forlot@iot.bzh>
Fri, 7 Dec 2018 16:36:38 +0000 (17:36 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 14 Dec 2018 08:59:41 +0000 (08:59 +0000)
Also formating and retabulating some comments

Change-Id: I95eda93e78fabeb336ca02e94307364954ab2318
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
12 files changed:
low-can-binding/binding/low-can-cb.cpp
low-can-binding/can/can-bus.hpp
low-can-binding/can/can-command.hpp
low-can-binding/can/can-message-definition.cpp
low-can-binding/can/can-message.cpp
low-can-binding/can/can-message.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/diagnostic/diagnostic-manager.hpp

index 098f071..d25f068 100644 (file)
@@ -256,9 +256,7 @@ static int subscribe_unsubscribe_can_signals(afb_req_t request,
                auto it =  std::find_if(s.begin(), s.end(), [&sig, &event_filter](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub){ return sub.second->is_signal_subscription_corresponding(sig, event_filter) ; });
                std::shared_ptr<low_can_subscription_t> can_subscription;
                if(it != s.end())
-               {
-                        can_subscription = it->second;
-               }
+                       {can_subscription = it->second;}
                else
                {
                         can_subscription = std::make_shared<low_can_subscription_t>(low_can_subscription_t(event_filter));
index 826d7c6..f1eb690 100644 (file)
@@ -62,7 +62,8 @@ private:
        std::mutex can_message_mutex_; ///< mutex protecting the can_message_q_ queue.
        std::queue <can_message_t> can_message_q_; ///< queue that will store can_message_t to be decoded
 
-       std::condition_variable new_decoded_can_message_; ///< condition_variable use to wait until there is a new vehicle message to read from the queue vehicle_message_q_
+       std::condition_variable new_decoded_can_message_; ///< condition_variable use to wait until there is a new vehicle message
+                                                         /// to read from the queue vehicle_message_q_
        std::mutex decoded_can_message_mutex_;  ///< mutex protecting the vehicle_message_q_ queue.
        std::queue <std::pair<int, openxc_VehicleMessage> > vehicle_message_q_; ///< queue that will store openxc_VehicleMessage to be pushed
 
index 4cf20cb..c64ad74 100644 (file)
@@ -51,5 +51,5 @@ typedef void (*CommandHandler)(const char* name, openxc_DynamicField* value,
 typedef struct {
        const char* generic_name; /*!< generic_name - The name of the command.*/
        CommandHandler handler; /*!< handler - An function to process the received command's data and perform some
-                                                        *      action.*/
+                                * action.*/
 } CanCommand;
index ae957d1..483f4a3 100644 (file)
 
 #include "../binding/application.hpp"
 
-can_message_definition_t::can_message_definition_t(const std::string bus)
-       : parent_{nullptr}, bus_{bus}, last_value_{CAN_MESSAGE_SIZE}
-{}
-
-can_message_definition_t::can_message_definition_t(
-       const std::string bus,
-       uint32_t id,
-       frequency_clock_t frequency_clock,
-       bool force_send_changed)
-       : parent_{nullptr},
-         bus_{bus},
-         id_{id},
-         frequency_clock_{frequency_clock},
-         force_send_changed_{force_send_changed},
-         last_value_{CAN_MESSAGE_SIZE}
-{}
-
-can_message_definition_t::can_message_definition_t(
-       const std::string bus,
-       uint32_t id,
-       can_message_format_t format,
-       frequency_clock_t frequency_clock,
-       bool force_send_changed)
-       : parent_{nullptr},
-       bus_{bus},
-       id_{id},
-       format_{format},
-       frequency_clock_{frequency_clock},
-       force_send_changed_{force_send_changed},
-       last_value_{CAN_MESSAGE_SIZE}
-{}
-
 can_message_definition_t::can_message_definition_t(
        const std::string bus,
        uint32_t id,
@@ -70,11 +38,6 @@ can_message_definition_t::can_message_definition_t(
        can_signals_{can_signals}
 {}
 
-const std::string can_message_definition_t::get_bus_name() const
-{
-       return bus_;
-}
-
 const std::string can_message_definition_t::get_bus_device_name() const
 {
        return application_t::instance().get_can_bus_manager()
@@ -104,4 +67,4 @@ void can_message_definition_t::set_parent(can_message_set_t* parent)
 void can_message_definition_t::set_last_value(const can_message_t& cm)
 {
        last_value_= cm.get_data_vector();
-}
\ No newline at end of file
+}
index 9ec3566..074f599 100644 (file)
@@ -71,38 +71,6 @@ int can_message_t::get_sub_id() const
        return sub_id_;
 }
 
-///
-/// @brief Retrieve RTR flag member.
-///
-/// @return rtr_flags_ class member
-///
-bool can_message_t::get_rtr_flag_() const
-{
-       return rtr_flag_;
-}
-
-///
-/// @brief Retrieve format_ member value.
-///
-/// @return format_ class member. Default to INVALID.
-///
-can_message_format_t can_message_t::get_format() const
-{
-       if (format_ != can_message_format_t::STANDARD || format_ != can_message_format_t::EXTENDED)
-               return can_message_format_t::INVALID;
-       return format_;
-}
-
-///
-/// @brief Retrieve flags_ member value.
-///
-/// @return flags_ class member
-///
-uint8_t can_message_t::get_flags() const
-{
-       return flags_;
-}
-
 ///
 /// @brief Retrieve data_ member value.
 ///
@@ -144,11 +112,6 @@ uint64_t can_message_t::get_timestamp() const
        return timestamp_;
 }
 
-void can_message_t::set_timestamp(uint64_t timestamp)
-{
-       timestamp_ = timestamp;
-}
-
 /// @brief Control whether the object is correctly initialized
 ///  to be sent over the CAN bus
 ///
@@ -165,20 +128,6 @@ bool can_message_t::is_correct_to_send()
        return false;
 }
 
-/// @brief Set format_ member value.
-///
-/// Preferred way to initialize these members is to use
-/// convert_from_canfd_frame method.
-///
-/// @param[in] new_format - class member
-void can_message_t::set_format(const can_message_format_t new_format)
-{
-       if(new_format == can_message_format_t::STANDARD || new_format == can_message_format_t::EXTENDED || new_format == can_message_format_t::INVALID)
-               format_ = new_format;
-       else
-               AFB_ERROR("Can set format, wrong format chosen");
-}
-
 /// @brief Take a canfd_frame struct to initialize class members
 ///
 /// This is the preferred way to initialize class members.
index cf960b9..032ef4d 100644 (file)
@@ -58,9 +58,6 @@ public:
 
        uint32_t get_id() const;
        int get_sub_id() const;
-       bool get_rtr_flag_() const;
-       can_message_format_t get_format() const;
-       uint8_t get_flags() const;
        const uint8_t* get_data() const;
        const std::vector<uint8_t> get_data_vector() const;
        uint8_t get_length() const;
@@ -68,7 +65,6 @@ public:
 
        void set_sub_id(int sub_id);
        void set_timestamp(uint64_t timestamp);
-       void set_format(const can_message_format_t new_format);
 
        bool is_correct_to_send();
 
index a964556..240436f 100644 (file)
@@ -79,11 +79,6 @@ const std::string can_signal_t::get_name() const
        return prefix_ + "." + generic_name_;
 }
 
-const std::string can_signal_t::get_prefix() const
-{
-       return prefix_;
-}
-
 uint8_t can_signal_t::get_bit_position() const
 {
        return bit_position_;
@@ -104,16 +99,6 @@ float can_signal_t::get_offset() const
        return offset_;
 }
 
-float can_signal_t::get_min_value() const
-{
-       return min_value_;
-}
-
-float can_signal_t::get_max_value() const
-{
-       return max_value_;
-}
-
 frequency_clock_t& can_signal_t::get_frequency()
 {
        return frequency_;
@@ -124,16 +109,6 @@ bool can_signal_t::get_send_same() const
        return send_same_;
 }
 
-bool can_signal_t::get_force_send_changed() const
-{
-       return force_send_changed_;
-}
-
-const std::map<uint8_t, std::string>& can_signal_t::get_states() const
-{
-       return states_;
-}
-
 const std::string can_signal_t::get_states(uint8_t value)
 {
        if (value < states_.size())
@@ -155,11 +130,6 @@ uint64_t can_signal_t::get_states(const std::string& value) const
        return ret;
 }
 
-size_t can_signal_t::get_state_count() const
-{
-       return states_.size();
-}
-
 bool can_signal_t::get_writable() const
 {
        return writable_;
@@ -195,11 +165,6 @@ void can_signal_t::set_parent(can_message_definition_t* parent)
        parent_ = parent;
 }
 
-void can_signal_t::set_prefix(std::string val)
-{
-       prefix_ = val;
-}
-
 void can_signal_t::set_received(bool r)
 {
        received_ = r;
index 331acdd..2fd7cec 100644 (file)
@@ -70,35 +70,35 @@ private:
        can_message_definition_t* parent_; /*!< parent_ - pointer to the parent message definition holding this signal*/
        std::string generic_name_; /*!< generic_name_ - The name of the signal to be output.*/
        static std::string prefix_; /*!< prefix_ - generic_name_ will be prefixed with it. It has to reflect the used protocol.
-                                                 * which make easier to sort message when the come in.*/
+                                    * which make easier to sort message when the come in.*/
        uint8_t bit_position_; /*!< bitPosition_ - The starting bit of the signal in its CAN message (assuming
-                                                                               *       non-inverted bit numbering, i.e. the most significant bit of
-                                                                               *       each byte is 0) */
+                               *       non-inverted bit numbering, i.e. the most significant bit of
+                               *       each byte is 0) */
        uint8_t bit_size_; /*!< bit_size_ - The width of the bit field in the CAN message. */
        float factor_; /*!< factor_ - The final value will be multiplied by this factor. Use 1 if you
-                                                       *       don't need a factor. */
+                       *       don't need a factor. */
        float offset_; /*!< offset_ - The final value will be added to this offset. Use 0 if you
-                                                       *       don't need an offset. */
+                       *       don't need an offset. */
        float min_value_; /*!< min_value_ - The minimum value for the processed signal.*/
        float max_value_; /*!< max_value_ - The maximum value for the processed signal. */
        frequency_clock_t frequency_; /*!< frequency_ - A frequency_clock_t struct to control the maximum frequency to
-                                                               *       process and send this signal. To process every value, set the
-                                                               *       clock's frequency to 0. */
+                                      * process and send this signal. To process every value, set the
+                                      * clock's frequency to 0. */
        bool send_same_; /*!< send_same_ - If true, will re-send even if the value hasn't changed.*/
        bool force_send_changed_; /*!< force_send_changed_ - If true, regardless of the frequency, it will send the
-                                                          * value if it has changed. */
+                                  * value if it has changed. */
        std::map<uint8_t, std::string> states_; /*!< states_ - A map of CAN signal state describing the mapping
-                                                                                * between numerical and string values for valid states. */
+                                                * between numerical and string values for valid states. */
        bool writable_; /*!< writable - True if the signal is allowed to be written from the USB host
-                                        *      back to CAN. Defaults to false.*/
+                        * back to CAN. Defaults to false.*/
        signal_decoder decoder_; /*!< decoder_ - An optional function to decode a signal from the bus to a human
-                                                        * readable value. If NULL, the default numerical decoder is used. */
+                                 * readable value. If NULL, the default numerical decoder is used. */
        signal_encoder encoder_; /*!< encoder_ - An optional function to encode a signal value to be written to
-                                                        * CAN into a byte array. If NULL, the default numerical encoder
-                                                        * is used. */
+                                 * CAN into a byte array. If NULL, the default numerical encoder
+                                 * is used. */
        bool received_; /*!< received_ - True if this signal has ever been received.*/
        float last_value_; /*!< lastValue_ - The last received value of the signal. If 'received' is false,
-                                               *       this value is undefined. */
+                           * this value is undefined. */
 
 public:
        can_signal_t(
@@ -121,20 +121,14 @@ public:
        can_message_definition_t* get_message() const;
        const std::string get_generic_name() const;
        const std::string get_name() const;
-       const std::string get_prefix() const;
        uint8_t get_bit_position() const;
        uint8_t get_bit_size() const;
        float get_factor() const;
        float get_offset() const;
-       float get_min_value() const;
-       float get_max_value() const;
        frequency_clock_t& get_frequency();
        bool get_send_same() const;
-       bool get_force_send_changed() const;
-       const std::map<uint8_t, std::string>& get_states() const;
        const std::string get_states(uint8_t value);
        uint64_t get_states(const std::string& value) const;
-       size_t get_state_count() const;
        bool get_writable() const;
        signal_decoder& get_decoder();
        signal_encoder& get_encoder();
@@ -143,7 +137,6 @@ public:
        std::pair<float, uint64_t> get_last_value_with_timestamp() const;
 
        void set_parent(can_message_definition_t* parent);
-       void set_prefix(std::string val);
        void set_received(bool r);
        void set_last_value(float val);
        void set_timestamp(uint64_t timestamp);
index 44ad47b..c5af449 100644 (file)
@@ -121,22 +121,6 @@ void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticR
        handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr));
 }
 
-///
-/// @brief Check if requested signal name is a diagnostic message. If the name
-///  begin with the diagnostic message prefix then true else false.
-///
-/// @param[in] name - A signal name.
-///
-/// @return true if name began with the diagnostic message prefix else false.
-///
-bool active_diagnostic_request_t::is_diagnostic_signal(const std::string& name)
-{
-       const std::string p = active_diagnostic_request_t::prefix_ + "*";
-       if(::fnmatch(p.c_str(), name.c_str(), FNM_CASEFOLD) == 0)
-               return true;
-       return false;
-}
-
 /// @brief Returns true if a sufficient response has been received for a
 /// diagnostic request.
 ///
index e32792a..effe932 100644 (file)
@@ -108,7 +108,5 @@ public:
 
        void set_handle(DiagnosticShims& shims, DiagnosticRequest* request);
 
-       static bool is_diagnostic_signal(const std::string& name);
-
        bool response_received() const;
 };
index 8932f25..ba4b0c8 100644 (file)
@@ -256,7 +256,7 @@ active_diagnostic_request_t* diagnostic_manager_t::find_recurring_request(Diagno
        }
        return nullptr;
 }
-
+/*
 /// @brief Add and send a new one-time diagnostic request. DON'T USED AT THIS TIME
 ///
 /// A one-time (aka non-recurring) request can existing in parallel with a
@@ -313,7 +313,7 @@ active_diagnostic_request_t* diagnostic_manager_t::add_request(DiagnosticRequest
        }
        return entry;
 }
-
+*/
 /// @brief Validate frequency asked don't get higher than the maximum of a classical
 /// CAN bus OBD2 request.
 ///
index 896a2b6..26c869e 100644 (file)
@@ -74,9 +74,9 @@ public:
        active_diagnostic_request_t* find_recurring_request(DiagnosticRequest& request);
 
        // Subscription parts
-       active_diagnostic_request_t* add_request(DiagnosticRequest* request, const std::string& name,
+       /*active_diagnostic_request_t* add_request(DiagnosticRequest* request, const std::string& name,
                bool waitForMultipleResponses, const DiagnosticResponseDecoder decoder,
-               const DiagnosticResponseCallback callback);
+               const DiagnosticResponseCallback callback);*/
        bool validate_optional_request_attributes(float frequencyHz);
        active_diagnostic_request_t* add_recurring_request(DiagnosticRequest* request, const char* name,
                bool waitForMultipleResponses, const DiagnosticResponseDecoder decoder,