X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=low-can-binding%2Fcan%2Fcan-message.cpp;h=9ec35668f482f3181d6877b5fcb902ae6fdd6888;hb=ea35eabeadce57e4f5015797fea530c5bb219fff;hp=1b27d0f62de3343a7ca6a0d57298451c2da15e0c;hpb=b049485873e1692cc9e7857e91e017f86dd91218;p=apps%2Fagl-service-can-low-level.git diff --git a/low-can-binding/can/can-message.cpp b/low-can-binding/can/can-message.cpp index 1b27d0f6..9ec35668 100644 --- a/low-can-binding/can/can-message.cpp +++ b/low-can-binding/can/can-message.cpp @@ -266,124 +266,3 @@ can_message_t can_message_t::convert_from_frame(const struct canfd_frame& frame, return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data, timestamp); } - -/// @brief Take a can_frame struct to initialize class members -/// -/// This is the preferred way to initialize class members. -/// -/// @param[in] frame - can_frame to convert coming from a read of CAN socket -/// @param[in] nbytes - bytes read from socket read operation. -/// -/// @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 = 0, length = 0, flags = 0; - uint32_t id; - can_message_format_t format; - bool rtr_flag; - std::vector data; - - if(nbytes <= CAN_MTU) - { - AFB_DEBUG("Got a legacy CAN frame"); - maxdlen = CAN_MAX_DLEN; - } - else - { - AFB_ERROR("unsupported CAN frame"); - } - - if (frame.can_id & CAN_ERR_FLAG) - { - format = can_message_format_t::INVALID; - id = frame.can_id & (CAN_ERR_MASK|CAN_ERR_FLAG); - } - else if (frame.can_id & CAN_EFF_FLAG) - { - format = can_message_format_t::EXTENDED; - id = frame.can_id & CAN_EFF_MASK; - } - else - { - format = can_message_format_t::STANDARD; - id = frame.can_id & CAN_SFF_MASK; - } - - /* Overwrite length_ if RTR flags is detected. - * standard CAN frames may have RTR enabled. There are no ERR frames with RTR */ - if (frame.can_id & CAN_RTR_FLAG) - { - rtr_flag = true; - if(frame.can_dlc && frame.can_dlc <= CAN_MAX_DLC) - { - if(rtr_flag) - length = frame.can_dlc& 0xF; - else - { - length = (frame.can_dlc > maxdlen) ? maxdlen : frame.can_dlc; - } - } - } - else - { - length = (frame.can_dlc > maxdlen) ? maxdlen : frame.can_dlc; - - if (data.capacity() < maxdlen) - data.reserve(maxdlen); - int i; - - data.clear(); - /* maxdlen_ is now set at CAN_MAX_DLEN or CANFD_MAX_DLEN, respectively 8 and 64 bytes*/ - for(i=0;i