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.
robomaster-sdk/src/message.c

19 lines
498 B
C

#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;
struct Footer* footer = (void*)message + length - sizeof(struct Footer);
if(footer->crc != crc16(message, length - sizeof(struct Footer)))
return MESSAGEERR_FOOTERCRC;
2 years ago
return MESSAGEERR_NONE;
}