X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=low-can-binding%2Fcan%2Fcan-encoder.cpp;h=4b8a2963b616384fc87aec98453f122cb6a53583;hb=refs%2Fchanges%2F49%2F18749%2F3;hp=d90e08da8db3cb81b46b5a18837ac7fef4abcadd;hpb=88befdfd812a58fb7a36e090278ad1e70003e925;p=apps%2Fagl-service-can-low-level.git diff --git a/low-can-binding/can/can-encoder.cpp b/low-can-binding/can/can-encoder.cpp index d90e08da..4b8a2963 100644 --- a/low-can-binding/can/can-encoder.cpp +++ b/low-can-binding/can/can-encoder.cpp @@ -28,14 +28,15 @@ /// @param[out] data - The destination buffer. /// @param[in] length - The length of the destination buffer. /// -/// @return Returns a can_frame struct initialized and ready to be send. -const can_frame encoder_t::build_frame(const std::shared_ptr& signal, uint64_t value) +/// @return Returns a canfd_frame struct initialized and ready to be send. +const canfd_frame encoder_t::build_frame(const std::shared_ptr& signal, uint64_t value) { - struct can_frame cf; + struct canfd_frame cf; ::memset(&cf, 0, sizeof(cf)); cf.can_id = signal->get_message()->get_id(); - cf.can_dlc = CAN_MAX_DLEN; + cf.len = signal->get_message()->is_fd() ? + CANFD_MAX_DLEN : CAN_MAX_DLEN; signal->set_last_value((float)value); @@ -43,12 +44,12 @@ const can_frame encoder_t::build_frame(const std::shared_ptr& sign { float last_value = sig->get_last_value(); bitfield_encode_float(last_value, - sig->get_bit_position(), - sig->get_bit_size(), - sig->get_factor(), - sig->get_offset(), - cf.data, - CAN_MAX_DLEN); + sig->get_bit_position(), + sig->get_bit_size(), + sig->get_factor(), + sig->get_offset(), + cf.data, + cf.len); } return cf;