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.
17 lines
401 B
C
17 lines
401 B
C
2 years ago
|
#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;
|
||
|
|
||
|
}
|
||
|
|