-/**
-* @brief Take a canfd_frame struct to initialize class members
-*
-* This is the preferred way to initialize class members.
-*
-* @param[in] args - struct read from can bus device.
-*/
-void can_message_t::convert_from_canfd_frame(const std::pair<struct canfd_frame&, size_t> args)
-{
- // May be it's overkill to assign member of the pair... May be it will change...
- struct canfd_frame frame = args.first;
- size_t nbytes = args.second;
- set_max_data_length(nbytes);
- set_length(frame.len);
- set_id_and_format(frame.can_id);
+ if (frame.can_id & CAN_ERR_FLAG)
+ format = can_message_format_t::ERROR;
+ else if (frame.can_id & CAN_EFF_FLAG)
+ format = can_message_format_t::EXTENDED;
+ else
+ format = can_message_format_t::STANDARD;
+
+ switch(format)
+ {
+ case can_message_format_t::STANDARD:
+ id = frame.can_id & CAN_SFF_MASK;
+ break;
+ case can_message_format_t::EXTENDED:
+ id = frame.can_id & CAN_EFF_MASK;
+ break;
+ case can_message_format_t::ERROR:
+ id = frame.can_id & (CAN_ERR_MASK|CAN_ERR_FLAG);
+ break;
+ default:
+ ERROR(binder_interface, "ERROR: Can set id, not a compatible format or format not set prior to set id.");
+ break;
+ }