generated from Alex4386/f0-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
191 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "utils.h" | ||
|
||
const char hex[] = "0123456789ABCDEF"; | ||
|
||
void print_bytes(char* tag, uint8_t* bytes, size_t len) { | ||
FURI_LOG_I("MTP", "Dumping bytes - TAG: %s", tag); | ||
int lines = len / 16; | ||
size_t last_line_len = len % 16; | ||
char* line = (char*)malloc(16 * 3 + 1); | ||
for(int i = 0; i < lines; i++) { | ||
int line_len = i == lines - 1 ? last_line_len : 16; | ||
for(int j = 0; j < line_len; j++) { | ||
// write hex without sprintf | ||
line[j * 3] = hex[bytes[i * 16 + j] >> 4]; | ||
line[j * 3 + 1] = hex[bytes[i * 16 + j] & 0x0F]; | ||
line[j * 3 + 2] = ' '; | ||
} | ||
line[16 * 3] = '\0'; | ||
FURI_LOG_I("MTP", line); | ||
} | ||
free(line); | ||
FURI_LOG_I("MTP", "End of dump - TAG: %s", tag); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
#include <furi.h> | ||
void print_bytes(char* tag, uint8_t* bytes, size_t len); |