fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35074?usp=email )


Change subject: soft_uart: demonstrate a problem with osmo_soft_uart_tx_ubits()
......................................................................

soft_uart: demonstrate a problem with osmo_soft_uart_tx_ubits()

As can be seen, pulling a small number of bits at a time (smaller
than a single UART frame would fit into) results in calling the
.tx_cb() with a msgb having no room at all, and thus pulling the
stop bits instead of the actual data.

Change-Id: Icfee378f0fdc5e32fe9ce0afab5f75bc278653a9
Related: OS#4396
---
M tests/soft_uart/soft_uart_test.c
M tests/soft_uart/soft_uart_test.ok
2 files changed, 85 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/74/35074/1

diff --git a/tests/soft_uart/soft_uart_test.c b/tests/soft_uart/soft_uart_test.c
index 20df207..4e85fe9 100644
--- a/tests/soft_uart/soft_uart_test.c
+++ b/tests/soft_uart/soft_uart_test.c
@@ -293,10 +293,30 @@
        osmo_soft_uart_free(suart);
 }

+static void test_tx_one_bit(void)
+{
+       struct osmo_soft_uart *suart;
+       ubit_t tx_buf[48];
+
+       suart = osmo_soft_uart_alloc(NULL, __func__, &suart_test_default_cfg);
+       OSMO_ASSERT(suart != NULL);
+
+       osmo_soft_uart_set_tx(suart, true);
+
+       g_tx_cb_cfg.data = (void *)"\xde\xad\xbe\xef";
+       g_tx_cb_cfg.data_len = 4;
+
+       printf("======== %s(): pulling %lu bits (one at a time)\n", __func__, 
sizeof(tx_buf));
+       for (unsigned int i = 0; i < sizeof(tx_buf); i++)
+               osmo_soft_uart_tx_ubits(suart, &tx_buf[i], 1);
+       printf("%s\n", osmo_ubit_dump(&tx_buf[0], sizeof(tx_buf)));
+}
+
 int main(int argc, char **argv)
 {
        test_rx();
        test_tx_rx();
+       test_tx_one_bit();

        return 0;
 }
diff --git a/tests/soft_uart/soft_uart_test.ok 
b/tests/soft_uart/soft_uart_test.ok
index e041104..5bde3fc 100644
--- a/tests/soft_uart/soft_uart_test.ok
+++ b/tests/soft_uart/soft_uart_test.ok
@@ -171,3 +171,53 @@
 test_tx_rx_exec_one(n_bits_total=32): 00000101 00000011 00000001 00000001
 suart_tx_cb(len=0/4):
 test_tx_rx_exec_one(n_bits_total=32): 11111111 11111111 11111111 11111111
+======== test_tx_one_bit(): pulling 48 bits (one at a time)
+suart_tx_cb(len=0/0): 
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+suart_tx_cb(len=0/0):
+111111111111111111111111111111111111111111111111

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35074?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Icfee378f0fdc5e32fe9ce0afab5f75bc278653a9
Gerrit-Change-Number: 35074
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanits...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to