On 25.07.19 09:04, Marc Kleine-Budde wrote:
On 7/24/19 8:07 PM, Oliver Hartkopp wrote:
If the CAN FD length was 12 before the modification and the modification
was to "set bit 0 in the length field" then you get 13.
ok
But the length value of 13 is an illegal value for CAN FD length and can
not been sent by a CAN FD controller.
ok, but that doesn't matter, because all CAN-FD drivers must convert
from struct canfd_frame::len to the dlc (== their register value)
anyways using the can_len2dlc() function.
Therefore we need a round-up to get the next valid CAN FD length value
(in our example it get's from 13 to 16).
I don't think this is needed, the user space might send such packets and
the drivers have to deal with then anyways.
Ok, maybe pointing to the driver lead to a wrong discussion.
We manipulate the length info and end with a CAN FD frame which has a
length which is unspecified in the CAN standard.
A valid CAN FD frame can not have a data length of 13.
So we fix this up after manipulation.
Neither the CAN controller nor the user reading from a socket should
ever get an invalid CAN FD frame.
Regards,
Oliver