You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
444 B
21 lines
444 B
#include "hexutils.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
const char* hex2str(uint8_t* data, uint32_t len) {
|
|
static char hex[256];
|
|
uint32_t i = 0;
|
|
for (i = 0; i < len; i++) {
|
|
sprintf(hex + i * 2, "%02X", data[i]);
|
|
}
|
|
hex[i * 2] = 0;
|
|
|
|
return hex;
|
|
}
|
|
|
|
const char* hex2str_ext(char* cache, int cachesize, uint8_t* data, uint32_t len) {
|
|
hex2str(data, len);
|
|
strncpy(cache, hex2str(data, len), cachesize);
|
|
return cache;
|
|
}
|