This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 8b9c64eecf lib_slcd: fix encode/decode of binary nibble to/from ascii
hex
8b9c64eecf is described below
commit 8b9c64eecf083c77dbbccc272407c39ab8240046
Author: Federico Braghiroli <[email protected]>
AuthorDate: Sun Dec 10 17:06:55 2023 +0100
lib_slcd: fix encode/decode of binary nibble to/from ascii hex
Binary nibble to/from ascii hex conversion was buggy on both
lib_slcdencode and lib_slcddecode libraries.
This bug caused the slcd library to fail to decode 5-byte sequence command
which have 'count' argument value bigger than 0x9.
Signed-off-by: Federico Braghiroli <[email protected]>
---
libs/libc/misc/lib_slcddecode.c | 2 +-
libs/libc/misc/lib_slcdencode.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/libc/misc/lib_slcddecode.c b/libs/libc/misc/lib_slcddecode.c
index 6ff5580ea6..df3f522112 100644
--- a/libs/libc/misc/lib_slcddecode.c
+++ b/libs/libc/misc/lib_slcddecode.c
@@ -87,7 +87,7 @@ static uint8_t slcd_nibble(uint8_t ascii)
}
else
{
- return ascii - 'a';
+ return ascii - 'a' + 10;
}
}
diff --git a/libs/libc/misc/lib_slcdencode.c b/libs/libc/misc/lib_slcdencode.c
index 2e512d4b23..f47b03f518 100644
--- a/libs/libc/misc/lib_slcdencode.c
+++ b/libs/libc/misc/lib_slcdencode.c
@@ -60,7 +60,7 @@ static uint8_t slcd_nibble(uint8_t binary)
}
else
{
- return 'a' + binary;
+ return 'a' + binary - 10;
}
}