Improve commenting
This commit is contained in:
@@ -12,7 +12,11 @@ uint16_t crc16(const void *block, size_t length);
|
|||||||
#define PACKED __attribute__((__packed__))
|
#define PACKED __attribute__((__packed__))
|
||||||
|
|
||||||
struct PACKED Header {
|
struct PACKED Header {
|
||||||
|
|
||||||
|
// The preamble marks the start of a message and is always 0x55
|
||||||
uint8_t preamble;
|
uint8_t preamble;
|
||||||
|
|
||||||
|
// The length of the message includes the preamble and CRC16 at the end
|
||||||
union {
|
union {
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
struct {
|
struct {
|
||||||
@@ -20,9 +24,20 @@ struct PACKED Header {
|
|||||||
uint8_t length_h;
|
uint8_t length_h;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This is a CRC8 checksum for the preamble and length together
|
||||||
uint8_t crc;
|
uint8_t crc;
|
||||||
|
|
||||||
|
// hostbyte of the message sender
|
||||||
uint8_t sender;
|
uint8_t sender;
|
||||||
|
|
||||||
|
// hostbyte of the message receiver
|
||||||
uint8_t receiver;
|
uint8_t receiver;
|
||||||
|
|
||||||
|
// Each message has a sequence ID
|
||||||
|
// The Robomaster will respond with the same ID for each request
|
||||||
|
// The value of the sequence ID doesn't matter to the Robomaster
|
||||||
|
// Repeating sequence IDs are acceptable
|
||||||
union {
|
union {
|
||||||
int16_t seq_id;
|
int16_t seq_id;
|
||||||
struct {
|
struct {
|
||||||
@@ -30,6 +45,9 @@ struct PACKED Header {
|
|||||||
uint8_t seq_id_h;
|
uint8_t seq_id_h;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The message attribute flags designate if a response is needed or if the
|
||||||
|
// message is a response.
|
||||||
union {
|
union {
|
||||||
uint8_t attribute;
|
uint8_t attribute;
|
||||||
struct {
|
struct {
|
||||||
@@ -38,8 +56,11 @@ struct PACKED Header {
|
|||||||
bool is_ack : 1;
|
bool is_ack : 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Each command has a cmdset and cmdid that together make a cmd key
|
||||||
uint8_t cmdset;
|
uint8_t cmdset;
|
||||||
uint8_t cmdid;
|
uint8_t cmdid;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PACKED Message {
|
struct PACKED Message {
|
||||||
|
|||||||
Reference in New Issue
Block a user