How to extract bytes from CAN_FRAME..?

Hi all.

Having a little trouble extracting bytes from a CAN_FRAME class.

Trying this…

CAN_FRAME ChalFrame;
CAN_FRAME RespFrame;


  if (Can0.available() > 0)

  // Split the Challenge into raw bytes

  ChalByte[0] = (ChalFrame & 0xFF000000)>>24;
  ChalByte[1] = (ChalFrame & 0x00FF0000)>>16;
  ChalByte[2] = (ChalFrame & 0x0000FF00)>>8;
  ChalByte[3] = (ChalFrame & 0x000000FF);

Gives error message “no match for ‘operator&’ (operand types are ‘CAN_FRAME’ and ‘unsigned int’)” in Arduino IDE.

I need to extract these bytes, modify them individually, then reassemble and send.

If you have any pointers please let me know!



Fixed thanks to Colin.

No need to use bit shifting.

 ChalByte[0] =[0];

Is appropriate :slight_smile: