]> Kevux Git Server - fll/commitdiff
Bugfix: The f_fss_simple_packet_encode() is not setting the entire size.
authorKevin Day <thekevinday@gmail.com>
Tue, 19 Dec 2023 05:18:43 +0000 (23:18 -0600)
committerKevin Day <thekevinday@gmail.com>
Tue, 19 Dec 2023 05:18:43 +0000 (23:18 -0600)
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

index b4ba948a1b5f834a0e9c22ae3e20ae578da64e76..0c321e0f32ff770654f7c1a120224ac8c6e25646 100644 (file)
@@ -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