From: Kevin Day Date: Tue, 19 Dec 2023 05:18:43 +0000 (-0600) Subject: Bugfix: The f_fss_simple_packet_encode() is not setting the entire size. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=8e83c51dad48272c6826a5e1f1a851e5ef4292d0;p=fll Bugfix: The f_fss_simple_packet_encode() is not setting the entire size. The code is casting to uint8_t too soon, causing the bytes after the first to be lost. --- diff --git a/level_0/f_fss/c/fss/simple_packet.c b/level_0/f_fss/c/fss/simple_packet.c index b4ba948..0c321e0 100644 --- a/level_0/f_fss/c/fss/simple_packet.c +++ b/level_0/f_fss/c/fss/simple_packet.c @@ -145,32 +145,32 @@ extern "C" { #ifdef _is_F_endian_little // Big Endian. if (control & F_fss_simple_packet_endian_d) { - destination->string[destination->used++] = ((uint8_t) size) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff; + destination->string[destination->used++] = (uint8_t) (size & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 8) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 16) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 24) & 0xff); } // Little Endian. else { - destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff; - destination->string[destination->used++] = ((uint8_t) size) & 0xff; + destination->string[destination->used++] = (uint8_t) ((size >> 24) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 16) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 8) & 0xff); + destination->string[destination->used++] = (uint8_t) (size & 0xff); } #else // Big Endian. if (control & F_fss_simple_packet_endian_d) { - destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff; - destination->string[destination->used++] = ((uint8_t) size) & 0xff; + destination->string[destination->used++] = (uint8_t) ((size >> 24) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 16) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 8) & 0xff); + destination->string[destination->used++] = (uint8_t) (size & 0xff); } // Little Endian. else { - destination->string[destination->used++] = ((uint8_t) size)) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff; - destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff; + destination->string[destination->used++] = (uint8_t) (size & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 8) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 16) & 0xff); + destination->string[destination->used++] = (uint8_t) ((size >> 24) & 0xff); } #endif // _is_F_endian_little