Now I have this project where I am reading some data and storing them as uint32_t.
To be able to read the individual bytes I have use 'union' as follows:
What I would like to know is whether or not its possible to use pointers or otherwise make the 'message.data' address same as 'in.bytes' so that I don't have to update 'data' everytime.
what i mean is something like that (tried it... does not work):-
however what I want to improve on (it possible) is not the sequencing of data but rather how to retieve data from memory location
currently the computed data is stored in 'in.tstamp, in.sData' memory location which is the same location as 'in.bytes'
I then have to put 'in.bytes' into 'message.data' (CAN message struct) before outputing it using 'send_msg'
I would like to get rid on the last step if possible by somehow making 'message.data[y]' share the same memory location as 'in.bytes[z]'.
'in' and 'message' are both global variables so it should be somehow possible, right? I just don't know how to make it work...
the stuct as mentioned in my inital post is part of a library and would like to about modifying it.
however what I want to improve on (it possible) is not the sequencing of data but rather how to retieve data from memory location
currently the computed data is stored in 'in.tstamp, in.sData' memory location which is the same location as 'in.bytes'
I then have to put 'in.bytes' into 'message.data' (CAN message struct) before outputing it using 'send_msg'
I would like to get rid on the last step if possible by somehow making 'message.data[y]' share the same memory location as 'in.bytes[z]'.
'in' and 'message' are both global variables so it should be somehow possible, right? I just don't know how to make it work...
the stuct as mentioned in my inital post is part of a library and would like to about modifying it.
I don't know how they can share the same memory if each data structure requires the bytes to be in a different order.