Misplaced test of rtr_flag bool and length assignation
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 8 Mar 2017 23:46:58 +0000 (00:46 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 16 Mar 2017 16:10:40 +0000 (17:10 +0100)
Mini simplification of the method... More incoming.

Change-Id: I2e7c2c5226e33265591acc6c8bbbe5f5f670db18
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
src/can/can-message.cpp

index cf57876..dd15c06 100644 (file)
@@ -166,11 +166,6 @@ can_message_t can_message_t::convert_to_canfd_frame(const struct canfd_frame& fr
                        break;
        }
 
-       if(rtr_flag)
-               length = frame.len& 0xF;
-       else
-               length = (frame.len > maxdlen) ? maxdlen : frame.len;
-
        if (frame.can_id & CAN_ERR_FLAG)
                format = can_message_format_t::ERROR;
        else if (frame.can_id & CAN_EFF_FLAG)
@@ -211,6 +206,8 @@ can_message_t can_message_t::convert_to_canfd_frame(const struct canfd_frame& fr
        }
        else
        {
+               length = (frame.len > maxdlen) ? maxdlen : frame.len;
+
                /* Flags field only present for CAN FD frames*/
                if(maxdlen == CANFD_MAX_DLEN)
                                flags = frame.flags & 0xF;