diff options
author | Keith Packard <keithp@keithp.com> | 2013-03-24 15:29:32 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-03-24 15:29:32 -0700 |
commit | dab354fe3060c4630f7843065295357f17e94aab (patch) | |
tree | 490b98653c3d6e4f59cadfce031a8f8b93da474b | |
parent | 32654ffde488570abbb4db53cc93251c35df7ea9 (diff) |
ao-tools/lib: Deal with binary USB data in debugging output
Dump non-ascii characters in hex format.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | ao-tools/lib/cc-usb.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ao-tools/lib/cc-usb.c b/ao-tools/lib/cc-usb.c index 9f07e662..621a15c1 100644 --- a/ao-tools/lib/cc-usb.c +++ b/ao-tools/lib/cc-usb.c @@ -140,7 +140,10 @@ cc_usb_dbg(int indent, uint8_t *bytes, int len) case '\n': eol = 1; default: - ccdbg_debug(CC_DEBUG_BITBANG, "%c", c); + if (c < ' ' || c > '~') + ccdbg_debug(CC_DEBUG_BITBANG, "\\%02x", c); + else + ccdbg_debug(CC_DEBUG_BITBANG, "%c", c); } } } @@ -190,6 +193,7 @@ _cc_usb_sync(struct cc_usb *cc, int wait_for_input) ret = read(cc->fd, cc->in_buf + cc->in_count, CC_IN_BUF - cc->in_count); if (ret > 0) { + int i; cc_usb_dbg(24, cc->in_buf + cc->in_count, ret); cc->in_count += ret; if (cc->hex_count) |