i have a Struct which consists of an Union which consists of an uint32_t and another (anonym) struct. It looks like this:
struct sMesswertNummer {
union {
uint32_t MesswertNummerFull;
struct {
uint16_t MesswertNummerPart:16;
uint16_t AggregatNummer:16;
uint8_t AggregatSub:8;
uint8_t AggregatTyp:8;
};
};
sMesswertNummer() { this->MesswertNummerFull=0; }
sMesswertNummer(uint16_t MesswertNummerPart,uint16_t AggregatNummer, uint8_t AggregatSub, uint8_t AggregatTyp) {
this->MesswertNummerFull=0;
this->MesswertNummerPart=MesswertNummerPart;
this->AggregatNummer=AggregatNummer;
this->AggregatSub=AggregatSub;
this->AggregatTyp=AggregatTyp;
}
};
I initialze the struct with a Call of the Constructor like this
MesswertNummer(0x0001,0x0002,0x30,0x02);
After that my Variable has the right values, Var.MesswertNummerPart
is 0x0001, Var.AggregatNummer
is 0x0002 and so on.
But if i call Var.MesswertNummerFull i get 0x0001 (is MesswertNummerPart) instead of 0x023000020001 (0x02->AggregatTyp, 0x30->AggregatSubm 0x0002->AggregatNummer, 0x0001->MesswertNummerPart)
How can i get the whole Number with a call of Var.MesswertNummerFull?