Skip to content

Commit 5aaf42c

Browse files
author
Ari Parkkila
committed
Cellular: ATHandler debugging relieved
1 parent f95ec95 commit 5aaf42c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ using namespace mbed_cellular_util;
3737
#define PROCESS_URC_TIME 20
3838

3939
// Suppress logging of very big packet payloads, maxlen is approximate due to write/read are cached
40-
#define DEBUG_MAXLEN 80
40+
#define DEBUG_MAXLEN 60
41+
#define DEBUG_END_MARK "..\r"
4142

4243
const char *mbed::OK = "OK\r\n";
4344
const uint8_t OK_LENGTH = 4;
@@ -463,7 +464,7 @@ ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len)
463464
}
464465
buf[read_len] = c;
465466
if (_debug_on && read_len >= DEBUG_MAXLEN) {
466-
debug_print("..", sizeof(".."));
467+
debug_print(DEBUG_END_MARK, sizeof(DEBUG_END_MARK) - 1);
467468
_debug_on = false;
468469
}
469470
}
@@ -555,9 +556,15 @@ ssize_t ATHandler::read_hex_string(char *buf, size_t size)
555556
size_t buf_idx = 0;
556557
char hexbuf[2];
557558

559+
bool debug_on = _debug_on;
558560
for (; read_idx < size * 2 + match_pos; read_idx++) {
559561
int c = get_char();
560562

563+
if (_debug_on && read_idx >= DEBUG_MAXLEN) {
564+
debug_print(DEBUG_END_MARK, sizeof(DEBUG_END_MARK) - 1);
565+
_debug_on = false;
566+
}
567+
561568
if (match_pos) {
562569
buf_idx++;
563570
} else {
@@ -595,6 +602,7 @@ ssize_t ATHandler::read_hex_string(char *buf, size_t size)
595602
}
596603
}
597604
}
605+
_debug_on = debug_on;
598606

599607
if (read_idx && (read_idx == size * 2 + match_pos)) {
600608
buf_idx++;
@@ -1168,7 +1176,7 @@ size_t ATHandler::write(const void *data, size_t len)
11681176
if (write_len + ret < DEBUG_MAXLEN) {
11691177
debug_print((char *)data + write_len, ret);
11701178
} else {
1171-
debug_print("..", sizeof(".."));
1179+
debug_print(DEBUG_END_MARK, sizeof(DEBUG_END_MARK) - 1);
11721180
_debug_on = false;
11731181
}
11741182
}
@@ -1228,7 +1236,7 @@ void ATHandler::debug_print(const char *p, int len)
12281236
debug("\n");
12291237
} else if (c == '\n') {
12301238
} else {
1231-
debug("[%d]", c);
1239+
debug("#%02x", c);
12321240
}
12331241
} else {
12341242
debug("%c", c);

0 commit comments

Comments
 (0)