Big-Endian CAN mapping

Post Reply
davefiddes
Posts: 235
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 20 times
Been thanked: 56 times

Big-Endian CAN mapping

Post 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.
User avatar
johu
Site Admin
Posts: 6027
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 203 times
Been thanked: 1161 times
Contact:

Re: Big-Endian CAN mapping

Post 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
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
davefiddes
Posts: 235
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 20 times
Been thanked: 56 times

Re: Big-Endian CAN mapping

Post by davefiddes »

The arithmetic reversing the position was confusing me...and I hadn't even started drinking. Sorry.
Post Reply