From 23f88ea19b78ccf34ce913c9e842042a5bde2289 Mon Sep 17 00:00:00 2001 From: Ben Artin Date: Mon, 20 Aug 2018 21:20:55 -0400 Subject: [PATCH 1/2] Fixed dbgDumpMemory for buffers > 255 bytes --- cores/nRF5/debug.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cores/nRF5/debug.cpp b/cores/nRF5/debug.cpp index a657b2d5..ae6644fc 100644 --- a/cores/nRF5/debug.cpp +++ b/cores/nRF5/debug.cpp @@ -177,15 +177,16 @@ void dbgPrintVersion(void) void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffset) { uint8_t const *buf8 = (uint8_t const *) buf; + + uint8_t format_size = 2 * size; + if ( count*size > UINT8_MAX ) format_size *= 2; + if ( count*size > UINT16_MAX ) format_size *= 2; char format[] = "%00lX"; - format[2] += 2*size; + format[2] += format_size; char offset_fmt[] = "%02lX: "; - if ( count*size > UINT8_MAX ) format[2] *= 2; - if ( count*size > UINT16_MAX ) format[2] *= 2; - const uint8_t item_per_line = 16 / size; for(int i=0; i Date: Mon, 20 Aug 2018 21:44:03 -0400 Subject: [PATCH 2/2] =?UTF-8?q?It=E2=80=99s=20the=20offset,=20not=20the=20?= =?UTF-8?q?data,=20that=20adusts=20to=20size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/nRF5/debug.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cores/nRF5/debug.cpp b/cores/nRF5/debug.cpp index ae6644fc..ff6b2915 100644 --- a/cores/nRF5/debug.cpp +++ b/cores/nRF5/debug.cpp @@ -179,13 +179,13 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs uint8_t const *buf8 = (uint8_t const *) buf; uint8_t format_size = 2 * size; - if ( count*size > UINT8_MAX ) format_size *= 2; - if ( count*size > UINT16_MAX ) format_size *= 2; + if ( count*size > UINT8_MAX ) offset_fmt_size *= 2; + if ( count*size > UINT16_MAX ) offset_fmt_size *= 2; - char format[] = "%00lX"; - format[2] += format_size; + char format[] = "%02lX"; - char offset_fmt[] = "%02lX: "; + char offset_fmt[] = "%00lX: "; + offset_fmt[2] += offset_fmt_size; const uint8_t item_per_line = 16 / size;