* limitations under the License.
*/
-#include "can/can-message.hpp"
+#include "can-message.hpp"
#include <cstring>
-#include "low-can-binding.hpp"
+#include "../low-can-binding.hpp"
-/********************************************************************************
-*
-* CanMessage method implementation
-*
-*********************************************************************************/
/**
* @brief Class constructor
*
: maxdlen_{0}, id_{0}, length_{0}, format_{can_message_format_t::ERROR}, rtr_flag_{false}, flags_{0}
{}
-can_message_t::can_message_t(uint8_t maxdlen, uint32_t id, uint8_t length, can_message_format_t format, bool rtr_flag_, uint8_t flags, std::vector<uint8_t> data)
- : maxdlen_{0}, id_{0}, length_{0}, format_{can_message_format_t::ERROR}, rtr_flag_{false}, flags_{0}, data_{data}
+can_message_t::can_message_t(uint8_t maxdlen, uint32_t id, uint8_t length, can_message_format_t format, bool rtr_flag, uint8_t flags, std::vector<uint8_t> data)
+ : maxdlen_{maxdlen}, id_{id}, length_{length}, format_{format}, rtr_flag_{rtr_flag}, flags_{flags}, data_{data}
{}
/**
/**
* @brief Retrieve flags_ member value.
*
-* @return flags_ class member
+* @return flags_ class member
*/
uint8_t can_message_t::get_flags() const
{
/**
* @brief Retrieve data_ member value.
*
-* @return pointer to the first element
+* @return pointer to the first element
* of class member data_
*/
const uint8_t* can_message_t::get_data() const
/**
* @brief Set format_ member value.
*
-* Preferred way to initialize these members by using
+* Preferred way to initialize these members by using
* convert_from_canfd_frame method.
*
* @param[in] new_format - class member
*
* This is the preferred way to initialize class members.
*
-* @param[in] args - struct read from can bus device.
+* @param[in] frame - canfd_frame to convert coming from a read of CAN socket
+* @param[in] nbyte - bytes read from socket read operation.
+*
+* @return A can_message_t object fully initialized with canfd_frame values.
*/
-can_message_t can_message_t::convert_to_canfd_frame(const struct canfd_frame& frame, size_t nbytes)
+can_message_t can_message_t::convert_from_canfd_frame(const struct canfd_frame& frame, size_t nbytes)
{
uint8_t maxdlen, length, flags = (uint8_t)NULL;
uint32_t id;
format = can_message_format_t::EXTENDED;
else
format = can_message_format_t::STANDARD;
-
+
switch(format)
{
case can_message_format_t::STANDARD:
else
{
length = (frame.len > maxdlen) ? maxdlen : frame.len;
- }
+ }
}
}
else
data.push_back(frame.data[i]);
};
- DEBUG(binder_interface, "convert_from_canfd_frame: Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
+ DEBUG(binder_interface, "convert_from_canfd_frame: Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
id, format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
}
/**
-* @brief Take all initialized class's members and build an
+* @brief Take all initialized class's members and build an
* canfd_frame struct that can be use to send a CAN message over
* the bus.
*
return frame;
}
-
-/********************************************************************************
-*
-* can_message_definition_t method implementation
-*
-*********************************************************************************/
-
-can_message_definition_t::can_message_definition_t(can_bus_dev_t& cbd)
- : bus_{cbd}, last_value_(CAN_MESSAGE_SIZE)
-{}
-
-uint32_t can_message_definition_t::get_id() const
-{
- return id_;
-}