diff --git a/ion/src/device/bench/command/command.cpp b/ion/src/device/bench/command/command.cpp index b8a41bdfc..645b224d9 100644 --- a/ion/src/device/bench/command/command.cpp +++ b/ion/src/device/bench/command/command.cpp @@ -30,11 +30,12 @@ bool isHex(char c) { return hexChar(c) >= 0; } -uint32_t hexNumber(const char * s) { +uint32_t hexNumber(const char * s, int maxLength) { uint32_t result = 0; - int8_t digit = 0; - while ((digit = hexChar(*s++)) >= 0) { - result = (result << 4) | digit; + int index = 0; + while ((maxLength < 0 || index < maxLength) && s[index] != NULL) { + result = (result << 4) | hexChar(s[index]); + index++; } return result; } diff --git a/ion/src/device/bench/command/command.h b/ion/src/device/bench/command/command.h index 5a749ed1d..5e5b9b857 100644 --- a/ion/src/device/bench/command/command.h +++ b/ion/src/device/bench/command/command.h @@ -31,7 +31,7 @@ extern const char * const sOFF; void reply(const char * s); int8_t hexChar(char c); bool isHex(char c); -uint32_t hexNumber(const char * s); +uint32_t hexNumber(const char * s, int maxLength = -1); } } diff --git a/ion/src/device/bench/command/print.cpp b/ion/src/device/bench/command/print.cpp index ec51a410b..8b5eb3bfc 100644 --- a/ion/src/device/bench/command/print.cpp +++ b/ion/src/device/bench/command/print.cpp @@ -15,8 +15,8 @@ void Print(const char * input) { return; } - char x = hexNumber(input); - char y = hexNumber(input+3); + char x = hexNumber(input, 2); + char y = hexNumber(input+3, 2); KDContext * ctx = KDIonContext::sharedContext(); ctx->drawString(input+6, KDPoint(x, y));