Improving readability of debug payload
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
18
hsm2040.h
18
hsm2040.h
@@ -14,19 +14,19 @@
|
||||
extern const uint8_t historical_bytes[];
|
||||
|
||||
#define DEBUG_PAYLOAD(p,s) { \
|
||||
TU_LOG3("Payload %s (%d bytes):\r\n", #p,s);\
|
||||
TU_LOG2("Payload %s (%d bytes):\r\n", #p,s);\
|
||||
for (int i = 0; i < s; i += 16) {\
|
||||
for (int j = 0; j < 16; j++) {\
|
||||
if (j < s-i) TU_LOG3("%02X ",p[i+j]);\
|
||||
else TU_LOG3(" ");\
|
||||
if (j == 7) TU_LOG3(" ");\
|
||||
} TU_LOG3(": "); \
|
||||
if (j < s-i) TU_LOG2("%02X ",p[i+j]);\
|
||||
else TU_LOG2(" ");\
|
||||
if (j == 7) TU_LOG2(" ");\
|
||||
} TU_LOG2(": "); \
|
||||
for (int j = 0; j < MIN(16,s-i); j++) {\
|
||||
TU_LOG3("%c",p[i+j]);\
|
||||
if (j == 7) TU_LOG3(" ");\
|
||||
TU_LOG2("%c",p[i+j] == 0x0a || p[i+j] == 0x0d ? '\\' : p[i+j]);\
|
||||
if (j == 7) TU_LOG2(" ");\
|
||||
}\
|
||||
TU_LOG3("\r\n");\
|
||||
} TU_LOG3("\r\n"); \
|
||||
TU_LOG2("\r\n");\
|
||||
} TU_LOG2("\r\n"); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user