///
/// @brief Class constructor
///
-/// Constructor about can_message_t class.
+/// can_message_t class constructor.
///
can_message_t::can_message_t()
: maxdlen_{0},
/// @brief Set format_ member value.
///
-/// Preferred way to initialize these members by using
+/// Preferred way to initialize these members is to use
/// convert_from_canfd_frame method.
///
/// @param[in] new_format - class member
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
- ERROR("Can set format, wrong format chosen");
+ AFB_ERROR("Can set format, wrong format chosen");
}
/// @brief Take a canfd_frame struct to initialize class members
/// @return A can_message_t object fully initialized with canfd_frame values.
can_message_t can_message_t::convert_from_frame(const struct canfd_frame& frame, size_t nbytes, uint64_t timestamp)
{
- uint8_t maxdlen, length, flags = (uint8_t)NULL;
+ uint8_t maxdlen = 0, length = 0, flags = 0;
uint32_t id;
can_message_format_t format;
bool rtr_flag;
switch(nbytes)
{
case CANFD_MTU:
- DEBUG("Got an CAN FD frame");
+ AFB_DEBUG("Got an CAN FD frame");
maxdlen = CANFD_MAX_DLEN;
break;
case CAN_MTU:
- DEBUG("Got a legacy CAN frame");
+ AFB_DEBUG("Got a legacy CAN frame");
maxdlen = CAN_MAX_DLEN;
break;
default:
- ERROR("unsupported CAN frame");
+ AFB_ERROR("unsupported CAN frame");
break;
}
data.push_back(frame.data[i]);
};
- DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
+ AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
/// @return A can_message_t object fully initialized with can_frame values.
can_message_t can_message_t::convert_from_frame(const struct can_frame& frame, size_t nbytes, uint64_t timestamp)
{
- uint8_t maxdlen, length, flags = (uint8_t)NULL;
+ uint8_t maxdlen = 0, length = 0, flags = 0;
uint32_t id;
can_message_format_t format;
bool rtr_flag;
if(nbytes <= CAN_MTU)
{
- DEBUG("Got a legacy CAN frame");
+ AFB_DEBUG("Got a legacy CAN frame");
maxdlen = CAN_MAX_DLEN;
}
else
{
- ERROR("unsupported CAN frame");
+ AFB_ERROR("unsupported CAN frame");
}
if (frame.can_id & CAN_ERR_FLAG)
data.push_back(frame.data[i]);
};
-// DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
+// AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
// id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data, timestamp);
}
-/// @brief Take all initialized class's members and build an
+/// @brief Take all initialized class members and build a
/// canfd_frame struct that can be use to send a CAN message over
/// the bus.
///
::memcpy(frame.data, get_data(), length_);
}
else
- ERROR("can_message_t not correctly initialized to be sent");
+ AFB_ERROR("can_message_t not correctly initialized to be sent");
return frame;
}
-/// @brief Take all initialized class's members and build an
+/// @brief Take all initialized class members and build a
/// can_frame struct that can be use to send a CAN message over
/// the bus.
///
::memcpy(frame.data, get_data(), length_);
}
else
- ERROR("can_message_t not correctly initialized to be sent");
+ AFB_ERROR("can_message_t not correctly initialized to be sent");
return frame;
}