Page 1 of 1

Big-Endian CAN mapping

Posted: Fri May 10, 2024 5:20 pm
by davefiddes
I'm looking at the big-endian CAN RX support with the intention of adding TX mapping support. The way the RX mapping doesn't make a lot of sense to me. It seems that the bit-order is reversed for the entire frame. If I look at Savvy CAN it is a lot more rational in that the byte order is reversed for the field itself but the position within a frame remains standard and unchanged. If there was a mix of big and little endian mappings on a device it would be easy to get in a muddle especially when working with established tools like Savvy CAN.

Re: Big-Endian CAN mapping

Posted: Fri May 10, 2024 5:57 pm
by johu
Hmm, the bit order shouldn't be changed at all, just the byte order:

Code: Select all

word = (bptr[0] << 24) | (bptr[1] << 16) | (bptr[2] << 8) | bptr[3];
I think it should be consistent with SavvyCAN that the position now specifies the "end" of the data item.

So little endian bit 0, length 16 becomes big endian bit 16, length -16

Or am I overlooking something?

viewtopic.php?t=4468

Re: Big-Endian CAN mapping

Posted: Sat May 11, 2024 10:01 am
by davefiddes
The arithmetic reversing the position was confusing me...and I hadn't even started drinking. Sorry.