diff --git a/include/message.h b/include/message.h index 76ebe18..09d5c6e 100644 --- a/include/message.h +++ b/include/message.h @@ -11,13 +11,7 @@ struct PACKED Header { uint8_t preamble; // The length of the message includes the preamble and CRC16 at the end - union { - uint16_t length; - struct { - uint8_t length_l; - uint8_t length_h; - }; - }; + uint16_t length; // This is a CRC8 checksum for the preamble and length together uint8_t crc; diff --git a/src/connection.c b/src/connection.c index ba62051..2b79b25 100644 --- a/src/connection.c +++ b/src/connection.c @@ -127,8 +127,8 @@ void req_finalize(struct Client* client, uint8_t cmdset, uint8_t cmdid, uint8_t hostbyte, bool need_ack, size_t length, union Request* req) { req->header.preamble = 0x55; - req->header.length_l = length & 0xFF; - req->header.length_h = ((length >> 8) & 0x3) | 4; + //req->header.length = length & 0x1FFF | 0x400; + req->header.length = length; req->header.crc = crc8(req, 3); req->header.seq_id = client->seq++; req->header.sender = client->hostbyte; diff --git a/src/message.c b/src/message.c index e7c4a39..50aab48 100644 --- a/src/message.c +++ b/src/message.c @@ -4,7 +4,7 @@ enum MESSAGEERR message_validate(const union Message* message) { - uint16_t length = (message->header.length_h & 0x3) * 0xFF + message->header.length_l; + uint16_t length = message->header.length; if(message->header.crc != crc8(message, 3)) return MESSAGEERR_HEADERCRC;