Move attributes flags and maxdlen 47/22247/3
authorArthur Guyader <arthur.guyader@iot.bzh>
Tue, 27 Aug 2019 12:40:08 +0000 (14:40 +0200)
committerArthur Guyader <arthur.guyader@iot.bzh>
Fri, 30 Aug 2019 09:46:04 +0000 (11:46 +0200)
This commit moves attributes flags and maxdlen from
class can_message_t to class message_t.

Bug-AGL : SPEC-2779

Change-Id: I56f9cd54d8b9822636311c603501326b36692cf4
Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
low-can-binding/can/message/can-message.cpp
low-can-binding/can/message/can-message.hpp
low-can-binding/can/message/j1939-message.cpp
low-can-binding/can/message/message.cpp
low-can-binding/can/message/message.hpp

index deca5c7..9bc8787 100644 (file)
@@ -29,8 +29,7 @@
 can_message_t::can_message_t()
        : message_t(),
         id_{0},
-        rtr_flag_{false},
-        flags_{0}
+        rtr_flag_{false}
 {}
 
 can_message_t::can_message_t(uint32_t maxdlen,
@@ -41,10 +40,9 @@ can_message_t::can_message_t(uint32_t maxdlen,
        uint32_t flags,
        std::vector<uint8_t>& data,
        uint64_t timestamp)
-       : message_t(maxdlen, length, format, data, timestamp),
+       : message_t(maxdlen, length, format, data, timestamp, flags),
        id_{id},
-       rtr_flag_{rtr_flag},
-       flags_{flags}
+       rtr_flag_{rtr_flag}
 {}
 
 ///
@@ -293,8 +291,3 @@ void can_message_t::set_bcm_msg(struct bcm_msg bcm_msg)
 {
        bcm_msg_ = bcm_msg;
 }
-
-uint32_t can_message_t::get_flags()
-{
-       return flags_;
-}
\ No newline at end of file
index 9e75887..76515d8 100644 (file)
@@ -35,7 +35,6 @@ class can_message_t : public message_t {
        private:
                uint32_t id_; ///< id_ - The ID of the message. */
                bool rtr_flag_; ///< rtr_flag_ - Telling if the frame has RTR flag positionned. Then frame hasn't data field*/
-               uint32_t flags_; ///< flags_ - flags of a CAN FD frame. Needed if we catch FD frames.*/
                struct bcm_msg bcm_msg_;
 
        public:
@@ -55,5 +54,5 @@ class can_message_t : public message_t {
                void set_bcm_msg(struct bcm_msg bcm_msg);
 
                std::string get_debug_message();
-               uint32_t get_flags();
+
 };
index 7dc388b..2d600a1 100644 (file)
@@ -36,7 +36,6 @@ j1939_message_t::j1939_message_t():
 /**
  * @brief Construct a new j1939 message t::j1939 message t object
  *
- * @param maxdlen The max length of the message
  * @param length The length of the message
  * @param format The format of the message
  * @param data The vector data of the message
@@ -45,15 +44,14 @@ j1939_message_t::j1939_message_t():
  * @param pgn The PGN of the message
  * @param addr The address of the message
  */
-j1939_message_t::j1939_message_t(uint32_t maxdlen,
-       uint32_t length,
+j1939_message_t::j1939_message_t(uint32_t length,
        message_format_t format,
        std::vector<uint8_t>& data,
        uint64_t timestamp,
        name_t name,
        pgn_t pgn,
        uint8_t addr):
-       message_t(maxdlen,length, format, data, timestamp),
+       message_t(J1939_MAX_DLEN,length, format, data, timestamp, 0),
        name_{name},
        pgn_{pgn},
        addr_{addr}
index b0a33f7..497304d 100644 (file)
@@ -30,7 +30,8 @@ message_t::message_t()
         length_{0},
         format_{message_format_t::INVALID},
         timestamp_{0},
-        sub_id_{-1}
+        sub_id_{-1},
+        flags_{0}
 {}
 
 /**
@@ -46,13 +47,15 @@ message_t::message_t(uint32_t maxdlen,
        uint32_t length,
        message_format_t format,
        std::vector<uint8_t>& data,
-       uint64_t timestamp)
+       uint64_t timestamp,
+       uint32_t flags)
        : maxdlen_{maxdlen},
        length_{length},
        format_{format},
        data_{data},
        timestamp_{timestamp},
-       sub_id_{-1}
+       sub_id_{-1},
+       flags_{flags}
 {}
 
 /**
@@ -169,3 +172,25 @@ message_format_t message_t::get_msg_format()
 {
        return format_;
 }
+
+
+uint32_t message_t::get_flags()
+{
+       return flags_;
+}
+
+void message_t::set_flags(uint32_t flags)
+{
+       flags_ = flags_ | flags;
+}
+
+uint32_t message_t::get_maxdlen()
+{
+       return maxdlen_;
+}
+
+
+void message_t::set_maxdlen(uint32_t maxdlen)
+{
+       maxdlen_ = maxdlen;
+}
\ No newline at end of file
index f0e1bf0..2182fe5 100644 (file)
@@ -55,12 +55,11 @@ protected:
        std::vector<uint8_t> data_; ///< data_ - The message's data field with a size of 8 which is the standard about CAN bus messages.*/
        uint64_t timestamp_; ///< timestamp_ - timestamp of the received message*/
        int sub_id_; ///< sub_id_ - Subscription index. */
-
-
+       uint32_t flags_; ///< flags_ - flags of a CAN FD frame. Needed if we catch FD frames.*/
 
 public:
        message_t();
-       message_t(uint32_t maxdlen, uint32_t length, message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp);
+       message_t(uint32_t maxdlen, uint32_t length, message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp, uint32_t flags);
        virtual ~message_t() = default;
 
        int get_sub_id() const;
@@ -77,5 +76,10 @@ public:
        virtual bool is_set() = 0;
        virtual std::string get_debug_message() = 0;
        virtual uint32_t get_id() const = 0;
+       uint32_t get_flags();
+       void set_flags(uint32_t flags);
+       uint32_t get_maxdlen();
+       void set_maxdlen(uint32_t maxdlen);
+
 
 };