From 62f60cc1519f114c5906cafaf49c34dc90729643 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sat, 13 Jul 2013 11:38:42 +0200 Subject: [PATCH] print lan-communication in verbose-mode --- hmland.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hmland.c b/hmland.c index 1a20bb9..3dae545 100644 --- a/hmland.c +++ b/hmland.c @@ -239,8 +239,13 @@ static int hmlan_format_out(uint8_t *buf, int buf_len, void *data) hexdump(buf, buf_len, "Unknown> "); break; } - if (debug) - fprintf(stderr, "LAN < %s\n", out); + if (verbose) { + int i; + + printf("LAN < "); + for (i = 0; i < outpos-out; i++) + printf("%c", out[i]); + } w = write(fd, out, outpos-out); if (w <= 0) { @@ -270,9 +275,6 @@ static int hmlan_parse_in(int fd, void *data) inpos = buf; - if (debug) - fprintf(stderr, "\nLAN > %s", buf); - while (inpos < inend) { uint8_t *instart = inpos; @@ -295,6 +297,13 @@ static int hmlan_parse_in(int fd, void *data) if (last == 0) continue; + if (verbose) { + printf("LAN > "); + for (i = 0; i < last; i++) + printf("%c", instart[i]); + printf("\n"); + } + memset(out, 0, sizeof(out)); *outpos++ = *inpos++; -- 2.39.5