You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
472 B
C
19 lines
472 B
C
#include "message.h"
|
|
#include "crc.h"
|
|
|
|
enum MESSAGEERR
|
|
message_validate(const union Message* message) {
|
|
|
|
uint16_t length = message->header.length & 0x1FFF & ~0x400;
|
|
|
|
if(message->header.crc != crc8(message, 3))
|
|
return MESSAGEERR_HEADERCRC;
|
|
|
|
struct Footer* footer = (void*)message + length - sizeof(struct Footer);
|
|
if(footer->crc != crc16(message, length - sizeof(struct Footer)))
|
|
return MESSAGEERR_FOOTERCRC;
|
|
|
|
return MESSAGEERR_NONE;
|
|
}
|
|
|