mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(log): Fixed incorrect argument type in hexdump log functions
Closes https://github.com/espressif/esp-idf/issues/13347 Thanks @matthew-8925
This commit is contained in:
parent
3c8b37087b
commit
4652a99e92
@ -205,6 +205,31 @@ TEST_CASE("log buffer")
|
|||||||
CHECK(regex_search(fix.get_print_buffer_string(), buffer_regex));
|
CHECK(regex_search(fix.get_print_buffer_string(), buffer_regex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("log bytes > 127")
|
||||||
|
{
|
||||||
|
PrintFixture fix(ESP_LOG_INFO);
|
||||||
|
const uint8_t buffer[] = {
|
||||||
|
0xff, 0x80,
|
||||||
|
};
|
||||||
|
ESP_LOG_BUFFER_HEX(TEST_TAG, buffer, sizeof(buffer));
|
||||||
|
const std::regex buffer_regex("I \\([0-9]*\\) test: ff 80", std::regex::ECMAScript);
|
||||||
|
CHECK(regex_search(fix.get_print_buffer_string(), buffer_regex));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("log buffer dump")
|
||||||
|
{
|
||||||
|
PrintFixture fix(ESP_LOG_INFO);
|
||||||
|
const uint8_t buffer[] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x05, 0x06, 0x07, 0x08,
|
||||||
|
0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8
|
||||||
|
};
|
||||||
|
ESP_LOG_BUFFER_HEXDUMP(TEST_TAG, buffer, sizeof(buffer), ESP_LOG_INFO);
|
||||||
|
const std::regex buffer_regex("I \\([0-9]*\\) test: 0x[0-9a-f]+\\s+"
|
||||||
|
"00 00 00 00 05 06 07 08 ff fe fd fc fb fa f9 f8 "
|
||||||
|
"\\s+|[\\.]{16}|", std::regex::ECMAScript);
|
||||||
|
CHECK(regex_search(fix.get_print_buffer_string(), buffer_regex));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("rom printf")
|
TEST_CASE("rom printf")
|
||||||
{
|
{
|
||||||
PutcFixture fix;
|
PutcFixture fix;
|
||||||
|
@ -48,7 +48,7 @@ void esp_log_buffer_hex_internal(const char *tag, const void *buffer, uint16_t b
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < bytes_cur_line; i ++) {
|
for (int i = 0; i < bytes_cur_line; i ++) {
|
||||||
sprintf(hex_buffer + 3 * i, "%02x ", ptr_line[i]);
|
sprintf(hex_buffer + 3 * i, "%02x ", (unsigned char) ptr_line[i]);
|
||||||
}
|
}
|
||||||
ESP_LOG_LEVEL(log_level, tag, "%s", hex_buffer);
|
ESP_LOG_LEVEL(log_level, tag, "%s", hex_buffer);
|
||||||
buffer += bytes_cur_line;
|
buffer += bytes_cur_line;
|
||||||
@ -100,7 +100,7 @@ void esp_log_buffer_hexdump_internal(const char *tag, const void *buffer, uint16
|
|||||||
const char *ptr_line;
|
const char *ptr_line;
|
||||||
//format: field[length]
|
//format: field[length]
|
||||||
// ADDR[10]+" "+DATA_HEX[8*3]+" "+DATA_HEX[8*3]+" |"+DATA_CHAR[8]+"|"
|
// ADDR[10]+" "+DATA_HEX[8*3]+" "+DATA_HEX[8*3]+" |"+DATA_CHAR[8]+"|"
|
||||||
char hd_buffer[10 + 3 + BYTES_PER_LINE * 3 + 3 + BYTES_PER_LINE + 1 + 1];
|
char hd_buffer[2 + sizeof(void *) * 2 + 3 + BYTES_PER_LINE * 3 + 1 + 3 + BYTES_PER_LINE + 1 + 1];
|
||||||
char *ptr_hd;
|
char *ptr_hd;
|
||||||
int bytes_cur_line;
|
int bytes_cur_line;
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ void esp_log_buffer_hexdump_internal(const char *tag, const void *buffer, uint16
|
|||||||
ptr_hd += sprintf(ptr_hd, " ");
|
ptr_hd += sprintf(ptr_hd, " ");
|
||||||
}
|
}
|
||||||
if (i < bytes_cur_line) {
|
if (i < bytes_cur_line) {
|
||||||
ptr_hd += sprintf(ptr_hd, " %02x", ptr_line[i]);
|
ptr_hd += sprintf(ptr_hd, " %02x", (unsigned char) ptr_line[i]);
|
||||||
} else {
|
} else {
|
||||||
ptr_hd += sprintf(ptr_hd, " ");
|
ptr_hd += sprintf(ptr_hd, " ");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user