diff --git a/sys/fmt/fmt.c b/sys/fmt/fmt.c index 1e70126931c5..dd3a7f014cfc 100644 --- a/sys/fmt/fmt.c +++ b/sys/fmt/fmt.c @@ -530,6 +530,13 @@ void print_byte_hex(uint8_t byte) print(buf, sizeof(buf)); } +void print_byte_dec(uint8_t byte) +{ + char buf[3]; /* "255" */ + size_t len = fmt_u32_dec(buf, byte); + print(buf, len); +} + void print_u32_hex(uint32_t val) { char buf[8]; diff --git a/sys/include/fmt.h b/sys/include/fmt.h index b1e0a286bb2f..626dc30e4a56 100644 --- a/sys/include/fmt.h +++ b/sys/include/fmt.h @@ -412,6 +412,13 @@ void print_u32_dec(uint32_t val); */ void print_s32_dec(int32_t val); +/** + * @brief Print byte value as dec to stdout + * + * @param[in] byte Byte value to print + */ +void print_byte_dec(const uint8_t byte); + /** * @brief Print byte value as hex to stdout * diff --git a/tests/fmt_print/main.c b/tests/fmt_print/main.c index 1b5ecfba274d..768f3f18fd6f 100644 --- a/tests/fmt_print/main.c +++ b/tests/fmt_print/main.c @@ -25,7 +25,10 @@ int main(void) { print_str("If you can read this:\n"); + for (int i = 0; i < 256; i++) { + print_byte_dec((uint8_t)i); + print_str("\n"); + } print_str("Test successful.\n"); - return 0; } diff --git a/tests/fmt_print/tests/01-run.py b/tests/fmt_print/tests/01-run.py index 9f6f3d734810..edab10113c5f 100755 --- a/tests/fmt_print/tests/01-run.py +++ b/tests/fmt_print/tests/01-run.py @@ -6,6 +6,8 @@ def testfunc(child): child.expect_exact('If you can read this:') + for i in range(0, 255): + child.expect_exact(str(i)) child.expect_exact('Test successful.')