1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18918 from benpicco/print_bytes_hex

sys/fmt: add print_bytes_hex()
This commit is contained in:
Kaspar Schleiser 2022-11-19 09:35:26 +01:00 committed by GitHub
commit 3cd9f0d8fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View File

@ -550,6 +550,15 @@ void print_byte_hex(uint8_t byte)
print(buf, sizeof(buf));
}
void print_bytes_hex(const void *bytes, size_t num)
{
const uint8_t *b = bytes;
while (num--) {
print_byte_hex(*b++);
}
}
void print_u32_hex(uint32_t val)
{
char buf[8];

View File

@ -450,6 +450,14 @@ void print_s32_dec(int32_t val);
*/
void print_byte_hex(uint8_t byte);
/**
* @brief Print bytes as hex to stdout
*
* @param[in] bytes Byte array to print
* @param[in] n Number of bytes to print
*/
void print_bytes_hex(const void *bytes, size_t n);
/**
* @brief Print uint32 value as hex to stdout
*

View File

@ -45,6 +45,8 @@ int main(void)
print_str("\n");
print_float(1.2345, 5);
print_str("\n");
print_bytes_hex("0123456789", 10);
print_str("\n");
/* test mixing of printf() and fmt's print() works fine */
printf("%s", "Test");
/* test fmt's print indeed only honors the length parameter and doesn't

View File

@ -15,6 +15,7 @@ def testfunc(child):
child.expect_exact('18446744073709551615')
child.expect_exact('-9223372036854775808')
child.expect_exact('1.23450')
child.expect_exact('30313233343536373839')
child.expect_exact('Test successful.')