How should I store a message encoded as bytes in a struct? I have a document with a table telling me the message format and it looks something like this:
field byte #
message signature 1
message length 2
value 1 (high byte) 3
value 1 (low byte) 4
value 2 (high byte) 5
value 2 (low byte) 6
value 3 (high byte) 7
value 3 (low byte) 8
checksum 9
so I'm going to take the input, parse it byte by byte and push those bytes into my struct. my questions are what types should I use for the struct members? should I combine the high/low bytes or leave them as pieces? does how you lay out the struct change if you plan to also write the message back later on?
struct hi_lo {
char hi;
char lo;
};
struct message {
char message_signature; //?
uint8_t message_signature; //?
...
uint16_t value1; //which
char value1[2]; //one
struct hi_lo value1; //should
char value1_hi; //I
char value1_lo; //use?
};