I have a structure which contains memory for an EEPROM:
#pragma pack(push,1)
struct EEPROM_Memory
{
char Device_ID[8];
uint8_t Version_No;
otherRandomVariables...
};
#pragma pack(pop)
I then create an instance, populate the struct and calculate it's CRC using:
CRC32::calculate(reinterpret_cast<uint8_t*>(&(memory)), sizeof(EEPROM_Memory));
I have been going crazy trying to figure out why the CRC check returns different values.
My best guess is pragma pack
is not working therefore there is still some padding. This padding is volatile thus resulting in different CRC values.
What would be a nice solution (i.e not manually checking each value in the struct for their CRC)?
Any suggestions much appreciated!
P.S. I have looked at this question but sadly it does not give many suggestions on what to do. Surely this is a common problem!
P.P.S I am using an ESP32 microcontroller, unsure which compiler. The CRC library I am using is CRC32 by Christopher Baker.