From: Gerhard Sittig Date: Sun, 19 Mar 2023 14:35:33 +0000 (+0100) Subject: rdtech-tc: rename "buflen" variable, it's "read length" X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e2bcf2e3b4190877c64ffdbb6a99d64a063cc402;p=libsigrok.git rdtech-tc: rename "buflen" variable, it's "read length" The 'buflen' variable name could be misleading, as it's not the receive buffer's size. Instead it is the amount of previously received response data. Rename it to 'rdlen'. --- diff --git a/src/hardware/rdtech-tc/protocol.c b/src/hardware/rdtech-tc/protocol.c index fd392884..ef1cd34b 100644 --- a/src/hardware/rdtech-tc/protocol.c +++ b/src/hardware/rdtech-tc/protocol.c @@ -167,7 +167,7 @@ SR_PRIV int rdtech_tc_poll(const struct sr_dev_inst *sdi, gboolean force) * Don't send the request while receive data is being accumulated. */ devc = sdi->priv; - if (!force && devc->buflen) + if (!force && devc->rdlen) return SR_OK; /* @@ -205,9 +205,9 @@ static int handle_poll_data(struct sr_dev_inst *sdi) float v; devc = sdi->priv; - sr_spew("Received poll packet (len: %zu).", devc->buflen); - if (devc->buflen < TC_POLL_LEN) { - sr_err("Insufficient poll packet length: %zu", devc->buflen); + sr_spew("Received poll packet (len: %zu).", devc->rdlen); + if (devc->rdlen < TC_POLL_LEN) { + sr_err("Insufficient poll packet length: %zu", devc->rdlen); return SR_ERR_DATA; } @@ -245,15 +245,15 @@ static int recv_poll_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *se /* Receive data became available. Drain the transport layer. */ devc = sdi->priv; - while (devc->buflen < TC_POLL_LEN) { - space = sizeof(devc->buf) - devc->buflen; + while (devc->rdlen < TC_POLL_LEN) { + space = sizeof(devc->buf) - devc->rdlen; len = serial_read_nonblocking(serial, - &devc->buf[devc->buflen], space); + &devc->buf[devc->rdlen], space); if (len < 0) return SR_ERR_IO; if (len == 0) return SR_OK; - devc->buflen += len; + devc->rdlen += len; } /* @@ -262,13 +262,13 @@ static int recv_poll_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *se */ /* Process packets when their reception has completed. */ - while (devc->buflen >= TC_POLL_LEN) { + while (devc->rdlen >= TC_POLL_LEN) { ret = handle_poll_data(sdi); if (ret != SR_OK) return ret; - devc->buflen -= TC_POLL_LEN; - if (devc->buflen) - memmove(&devc->buf[0], &devc->buf[TC_POLL_LEN], devc->buflen); + devc->rdlen -= TC_POLL_LEN; + if (devc->rdlen) + memmove(devc->buf, &devc->buf[TC_POLL_LEN], devc->rdlen); } return SR_OK; diff --git a/src/hardware/rdtech-tc/protocol.h b/src/hardware/rdtech-tc/protocol.h index 6458460a..fb025906 100644 --- a/src/hardware/rdtech-tc/protocol.h +++ b/src/hardware/rdtech-tc/protocol.h @@ -49,7 +49,7 @@ struct dev_context { struct feed_queue_analog **feeds; struct sr_sw_limits limits; uint8_t buf[RDTECH_TC_BUFSIZE]; - size_t buflen; + size_t rdlen; int64_t cmd_sent_at; };