So I am currently working on project and I need to make a hex array which I later send over serial. This hex array has some fixed parts, for example it begins with F0 always but in the middle I need to have variable data. What would be the easiest way to add variables to this hex array?
Here is a rough example of what I want to do:
F0 (2 byte long variable) (1 byte variable) (4 byte long variable) 0F
Example:
F0 00 01 FF 00 00 00 01 0F
So ideally this is something im looking for:
unsigned char data[] = {0xF0,Data1,Data2,Data3,0x0F};
Assuming the stream uses the same endianness as the machine sending the data, you can copy data in variables using
memcpy()function.