Ben
Well-known member
Hi,
I'm using a Struct for some calibration data, this way I can easily save and load the data from EEPROM using EEPROM.get and EEPROM.put. This works great, now I'd like to add a CRC checksum using Frank's FastCRC library. FastCRC expects the data as a char array, so I created a union containing the struct and a char array of the same size. This does not compile as the union's constructor seems to get implicitly deleted. Here's a minimal example to reproduce the problem:
My intention was to then use the FastCRC function somewhat like so:
If there is a better or more elegant way to use FastCRC on a struct I'd happily abandon the whole struct-in-union contraption ...
Cheers
Ben
I'm using a Struct for some calibration data, this way I can easily save and load the data from EEPROM using EEPROM.get and EEPROM.put. This works great, now I'd like to add a CRC checksum using Frank's FastCRC library. FastCRC expects the data as a char array, so I created a union containing the struct and a char array of the same size. This does not compile as the union's constructor seems to get implicitly deleted. Here's a minimal example to reproduce the problem:
Code:
struct S1 {
uint32_t foo = 0x00;
uint32_t crc = 0x00;
};
union U1 {
S1 s;
uint8_t c[8];
};
U1 u;
void setup() {}
void loop() {}
My intention was to then use the FastCRC function somewhat like so:
Code:
CRC32.crc32(u.c, sizeof(u.s - 4))
If there is a better or more elegant way to use FastCRC on a struct I'd happily abandon the whole struct-in-union contraption ...
Cheers
Ben