Extract bits and bytes from a CAN Bus message

  c++, can-bus

I have a 8 byte CAN Bus message

15 E0 7F 34 17 5C 2 33 

There is for example MCU_SelfCheckStatus at bit 52 and one bit long.
Or MCU_MotorTemp at bit 47 and 8 bits long.

The endianess is Motorola.
My readers endianess is little endian.

What would be an easy way to get them as a labeled data structure? Like:

bool isOk = msg.MCU_SelfCheckStatus;
uint8_t temp = msg.MCU_MotorTemp;

I thought about unions but I don’t know if they allow such things.

Source: Windows Questions C++

LEAVE A COMMENT