From 8e83c51dad48272c6826a5e1f1a851e5ef4292d0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 18 Dec 2023 23:18:43 -0600 Subject: [PATCH] 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. --- level_0/f_fss/c/fss/simple_packet.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 -- 1.8.3.1