esp_log_buffer_hex: Make buffer argument a void pointer
This commit is contained in:
parent
e7db29b2a8
commit
edd2459934
2 changed files with 6 additions and 5 deletions
|
@ -102,10 +102,10 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||||
*
|
*
|
||||||
* @param buffer Pointer to the buffer array
|
* @param buffer Pointer to the buffer array
|
||||||
*
|
*
|
||||||
* @param buff_len length of buffer
|
* @param buff_len length of buffer in bytes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len);
|
void esp_log_buffer_hex(const char *tag, const void *buffer, uint16_t buff_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Log a buffer of characters at Info level. Buffer should contain only printable characters.
|
* @brief Log a buffer of characters at Info level. Buffer should contain only printable characters.
|
||||||
|
@ -114,7 +114,7 @@ void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len);
|
||||||
*
|
*
|
||||||
* @param buffer Pointer to the buffer array
|
* @param buffer Pointer to the buffer array
|
||||||
*
|
*
|
||||||
* @param buff_len length of buffer
|
* @param buff_len length of buffer in bytes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void esp_log_buffer_char(const char *tag, const char *buffer, uint16_t buff_len);
|
void esp_log_buffer_char(const char *tag, const char *buffer, uint16_t buff_len);
|
||||||
|
|
|
@ -319,12 +319,13 @@ uint32_t esp_log_timestamp() __attribute__((alias("esp_log_early_timestamp")));
|
||||||
|
|
||||||
#endif //BOOTLOADER_BUILD
|
#endif //BOOTLOADER_BUILD
|
||||||
|
|
||||||
void esp_log_buffer_hex(const char *tag, const char *buffer, uint16_t buff_len)
|
void esp_log_buffer_hex(const char *tag, const void *buffer, uint16_t buff_len)
|
||||||
{
|
{
|
||||||
|
const char *as_bytes = (const char *)buffer;
|
||||||
char temp_buffer[3*BYTES_PER_LINE + 1]= {0};
|
char temp_buffer[3*BYTES_PER_LINE + 1]= {0};
|
||||||
int line_len = 0;
|
int line_len = 0;
|
||||||
for (int i = 0; i < buff_len; i++) {
|
for (int i = 0; i < buff_len; i++) {
|
||||||
line_len += sprintf(temp_buffer+line_len, "%02x ", buffer[i]);
|
line_len += sprintf(temp_buffer+line_len, "%02x ", as_bytes[i]);
|
||||||
if (((i + 1) % BYTES_PER_LINE == 0) || (i == buff_len - 1)) {
|
if (((i + 1) % BYTES_PER_LINE == 0) || (i == buff_len - 1)) {
|
||||||
ESP_LOGI(tag, "%s", temp_buffer);
|
ESP_LOGI(tag, "%s", temp_buffer);
|
||||||
line_len = 0;
|
line_len = 0;
|
||||||
|
|
Loading…
Reference in a new issue