I have an array of structs of type can_frame, defined in can.h as the following:
struct can_frame {
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
__u8 __pad; /* padding */
__u8 __res0; /* reserved / padding */
__u8 __res1; /* reserved / padding */
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
};
I initialize the structs like this:
struct can_frame frame2;
frame2.can_id = 0x124;
frame2.can_dlc = 8;
frame2.data[0] = 0x00;
frame2.data[1] = 0x01;
The array is created like this:
struct can_frame frames[2];
frames[0] = frame;
frames[1] = frame2;
Later, in the same function, but in a while loop, I'm trying to change one byte from the data array, from one of the frames. First, I try to get a pointer to one of the frames, to work with it further:
struct can_frame* to_change = &(frames[change_frame]);
Later, I try to update one of the values like this:
to_change->data[update_index] = anotherRandomNumber;
However, the value in the original frame doesn't change. What do I need to do differently, to change the value in the original, instead of a copy?