From: Gerhard Sittig Date: Sun, 19 Mar 2023 15:09:18 +0000 (+0100) Subject: rdtech-tc: dump response payload at higher log levels X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1dfda32f8498680fdcb27027a21de9ea50cc2a4b;p=libsigrok.git rdtech-tc: dump response payload at higher log levels The request is sent as is, responses are AES encrypted. Which voids the point of transport layer dumps. Extend the rdtech-tc device driver, dump the response content at spew levels after successful AES decryption and validity checks. Pick a bytes per line count which matches the 64 bytes chunked layout, yet reduces the number of created log output lines. --- diff --git a/src/hardware/rdtech-tc/protocol.c b/src/hardware/rdtech-tc/protocol.c index 9320b84f..649489fe 100644 --- a/src/hardware/rdtech-tc/protocol.c +++ b/src/hardware/rdtech-tc/protocol.c @@ -122,6 +122,30 @@ static int process_poll_pkt(struct dev_context *devc, uint8_t *dst) return SR_ERR_DATA; } + if (sr_log_loglevel_get() >= SR_LOG_SPEW) { + static const size_t chunk_max = 32; + + const uint8_t *rdptr; + size_t rdlen, chunk_addr, chunk_len; + GString *txt; + + sr_spew("check passed on decrypted receive data"); + rdptr = dst; + rdlen = TC_POLL_LEN; + chunk_addr = 0; + while (rdlen) { + chunk_len = rdlen; + if (chunk_len > chunk_max) + chunk_len = chunk_max; + txt = sr_hexdump_new(rdptr, chunk_len); + sr_spew("%04zx %s", chunk_addr, txt->str); + sr_hexdump_free(txt); + chunk_addr += chunk_len; + rdptr += chunk_len; + rdlen -= chunk_len; + } + } + return SR_OK; }