#include "message.h" #include "crc.h" enum MESSAGEERR message_validate(const union Message* message) { uint16_t length = (message->header.length_h & 0x3) * 0xFF + message->header.length_l; if(message->header.crc != crc8(message, 3)) return MESSAGEERR_HEADERCRC; if(message->header.crc != crc16(message, length - sizeof(struct Footer))) return MESSAGEERR_FOOTERCRC; }