Improve commenting

refactor
PgSocks 2 years ago
parent c721dc756c
commit a1c9c2fc00

@ -12,7 +12,11 @@ uint16_t crc16(const void *block, size_t length);
#define PACKED __attribute__((__packed__))
struct PACKED Header {
// The preamble marks the start of a message and is always 0x55
uint8_t preamble;
// The length of the message includes the preamble and CRC16 at the end
union {
uint16_t length;
struct {
@ -20,9 +24,20 @@ struct PACKED Header {
uint8_t length_h;
};
};
// This is a CRC8 checksum for the preamble and length together
uint8_t crc;
// hostbyte of the message sender
uint8_t sender;
// hostbyte of the message 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 {
int16_t seq_id;
struct {
@ -30,6 +45,9 @@ struct PACKED Header {
uint8_t seq_id_h;
};
};
// The message attribute flags designate if a response is needed or if the
// message is a response.
union {
uint8_t attribute;
struct {
@ -38,8 +56,11 @@ struct PACKED Header {
bool is_ack : 1;
};
};
// Each command has a cmdset and cmdid that together make a cmd key
uint8_t cmdset;
uint8_t cmdid;
};
struct PACKED Message {

Loading…
Cancel
Save