Skip to content

Commit e132b3e

Browse files
committed
Add: API __debug_buf() to view chars pointered by a char* pointer
1 parent 5ff5539 commit e132b3e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cores/arduino/Arduino.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ void init( void );
6464
void setup( void ) ;
6565
void loop( void ) ;
6666

67+
int __debug_buf(const char* head, char* buf, int len);
68+
6769
#include "WVariant.h"
6870

6971
#ifdef __cplusplus

cores/arduino/Retarget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ int __wrap__write (int fd, const char *ptr, int len) {
7373
return len;
7474
}
7575

76+
int __debug_buf(const char* head, char* buf, int len) {
77+
int i;
78+
79+
printf("\nDBG:%s[%d] = \r\n\t", head, len);
80+
for (i = 0; i < len; i++) {
81+
printf("%.2X ", buf[i]);
82+
if ((i & 0xFUL) == 0xFUL && i != len - 1) {
83+
printf("\r\n\t");
84+
}
85+
}
86+
printf("\r\n");
87+
return len;
88+
}
89+
7690
#ifdef __cplusplus
7791
}
7892
#endif

0 commit comments

Comments
 (0)