]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-tc: dump response payload at higher log levels
authorGerhard Sittig <redacted>
Sun, 19 Mar 2023 15:09:18 +0000 (16:09 +0100)
committerGerhard Sittig <redacted>
Sun, 19 Mar 2023 21:40:08 +0000 (22:40 +0100)
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.

src/hardware/rdtech-tc/protocol.c

index 9320b84fafa5435578dfed04c3a217440df6cba5..649489feeb0da6e0fa106e9035f23ab9f6150661 100644 (file)
@@ -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;
 }