X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Funi-t-dmm%2Fprotocol.c;h=bd231160fee51633708e60bcbf64159fc296c98d;hb=HEAD;hp=111770838f077310559b8fbbbc765c995734d2c1;hpb=ca314e060f653e6a0b5ec0f58914bac4d426217f;p=libsigrok.git diff --git a/src/hardware/uni-t-dmm/protocol.c b/src/hardware/uni-t-dmm/protocol.c index 11177083..bd231160 100644 --- a/src/hardware/uni-t-dmm/protocol.c +++ b/src/hardware/uni-t-dmm/protocol.c @@ -164,10 +164,11 @@ static void log_8byte_chunk(const uint8_t *buf) static void log_dmm_packet(const uint8_t *buf) { - sr_dbg("DMM packet: %02x %02x %02x %02x %02x %02x %02x" - " %02x %02x %02x %02x %02x %02x %02x", - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], - buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]); + GString *text; + + text = sr_hexdump_new(buf, 14); + sr_dbg("DMM packet: %s", text->str); + sr_hexdump_free(text); } static int get_and_handle_data(struct sr_dev_inst *sdi) @@ -258,8 +259,8 @@ static int get_and_handle_data(struct sr_dev_inst *sdi) } /* Move remaining bytes to beginning of buffer. */ - for (i = 0; i < devc->buflen - devc->bufoffset; i++) - pbuf[i] = pbuf[devc->bufoffset + i]; + if (devc->bufoffset < devc->buflen) + memmove(pbuf, pbuf + devc->bufoffset, devc->buflen - devc->bufoffset); devc->buflen -= devc->bufoffset; return SR_OK;