laforge submitted this change.
soft_uart: osmo_soft_uart_tx_ubits(): return number of bits pulled
This is a partial revert of 0887188c6b133b69142965d65e1be8a0696a6272.
We actually want to return number of bits pulled, because in the upcoming
commit implementing the flow control we want to be able to signal to the
caller that the buffer was not completely filled, but only partly.
Change-Id: I47a56f0fc36f2bc8f5a797d7fec64dfb56842388
Related: OS#4396
---
M src/core/soft_uart.c
M tests/soft_uart/soft_uart_test.c
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c
index a1888d6..5750282 100644
--- a/src/core/soft_uart.c
+++ b/src/core/soft_uart.c
@@ -277,7 +277,7 @@
* \param[in] suart soft-UART instance to pull the bits from.
* \param[out] ubits pointer to a buffer where to store pulled bits.
* \param[in] n_ubits number of unpacked bits to be pulled.
- * \returns 0 on success; negative on error.
+ * \returns number of bits pulled; negative on error.
* -EAGAIN indicates that the transmitter is disabled. */
int osmo_soft_uart_tx_ubits(struct osmo_soft_uart *suart, ubit_t *ubits, size_t n_ubits)
{
@@ -318,7 +318,7 @@
ubits[i] = suart_tx_bit(suart, msg);
msgb_free(msg);
- return 0;
+ return n_ubits;
}
/*! Set the modem status lines of the given soft-UART.
diff --git a/tests/soft_uart/soft_uart_test.c b/tests/soft_uart/soft_uart_test.c
index 276ffe1..ef64855 100644
--- a/tests/soft_uart/soft_uart_test.c
+++ b/tests/soft_uart/soft_uart_test.c
@@ -217,7 +217,7 @@
int rc;
rc = osmo_soft_uart_tx_ubits(suart, &tx_buf[0], n_bits_total);
- OSMO_ASSERT(rc == 0);
+ OSMO_ASSERT(rc == n_bits_total);
rc = osmo_soft_uart_rx_ubits(suart, &tx_buf[0], n_bits_total);
OSMO_ASSERT(rc == 0);
@@ -332,7 +332,7 @@
printf("======== %s(): pulling %lu bits (%u at a time)\n", __func__, sizeof(tx_buf), n);
for (unsigned int i = 0; i < sizeof(tx_buf); i += n) {
rc = osmo_soft_uart_tx_ubits(suart, &tx_buf[i], n);
- OSMO_ASSERT(rc == 0);
+ OSMO_ASSERT(rc == n);
}
printf("%s\n", osmo_ubit_dump(&tx_buf[0], sizeof(tx_buf)));
To view, visit change 35204. To unsubscribe, or for help writing mail filters, visit settings.