mirror of https://gerrit.osmocom.org/libosmocore
soft_uart: demonstrate a problem with manual flush()ing
This problem can only happen if the user is flush()ing the Rx buffer manually by calling osmo_soft_uart_flush_rx(). Let's demonstrate it in the unit test, so that we don't forget about it (add FIXME). Change-Id: Iad932a505d6fd98360f90510651501f8708ff5d2
This commit is contained in:
parent
d76cc3704e
commit
b392099602
|
@ -226,6 +226,7 @@ static void test_rx(void)
|
|||
|
||||
static void test_rx_flush(void)
|
||||
{
|
||||
struct osmo_soft_uart_cfg cfg;
|
||||
struct osmo_soft_uart *suart;
|
||||
|
||||
SUART_TEST_BEGIN;
|
||||
|
@ -242,6 +243,25 @@ static void test_rx_flush(void)
|
|||
printf("calling osmo_soft_uart_flush_rx() while Rx enabled, but no data\n");
|
||||
osmo_soft_uart_flush_rx(suart);
|
||||
|
||||
/* FIXME: this scenario demonstrates a problem that may occur when the user
|
||||
* flushes the Rx buffer manually while the soft-UART state reflects flags
|
||||
* of an incomplete symbol, for which we're waiting the stop bit. */
|
||||
printf("testing corner case: manual flushing during a parity error (8-E-1)\n");
|
||||
cfg = suart_test_default_cfg;
|
||||
cfg.parity_mode = OSMO_SUART_PARITY_EVEN;
|
||||
osmo_soft_uart_configure(suart, &cfg);
|
||||
test_rx_exec(suart, "1111111" /* no data */
|
||||
"0 01010101 0 1" /* even parity, correct */
|
||||
"0 10101010 0 1" /* even parity, correct */
|
||||
"0 11111111 1" /* odd parity, incorrect, but stop bit is pending */
|
||||
"F" /* manual flush happens before receiving the stop bit */
|
||||
"1" /* finally, the stop bit is received */
|
||||
);
|
||||
/* test_rx_exec() @ 47: flush the Rx buffer
|
||||
* suart_rx_cb(flags=02): aa 55 <--- this is wrong, should be flags=00
|
||||
* suart_rx_cb(flags=02): ff <--- this is expected due to odd parity */
|
||||
|
||||
|
||||
osmo_soft_uart_free(suart);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,10 @@ Executing test_rx_flush
|
|||
calling osmo_soft_uart_flush_rx() while Rx disabled
|
||||
enabling the receiver
|
||||
calling osmo_soft_uart_flush_rx() while Rx enabled, but no data
|
||||
testing corner case: manual flushing during a parity error (8-E-1)
|
||||
test_rx_exec() @ 47: flush the Rx buffer
|
||||
suart_rx_cb(flags=02): aa 55
|
||||
suart_rx_cb(flags=02): ff
|
||||
|
||||
Executing test_tx_rx
|
||||
======== testing 8-N-1
|
||||
|
|
Loading…
Reference in New Issue