fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35066?usp=email )

 (

4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: soft_uart: fix handling of num_data_bits < 8
......................................................................

soft_uart: fix handling of num_data_bits < 8

Change-Id: Ife13b1f2d9063ba7253d01523ca9ecb15e9eaf07
Related: OS#4396
---
M src/core/soft_uart.c
M tests/soft_uart/soft_uart_test.ok
2 files changed, 17 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  jolly: Looks good to me, but someone else must approve




diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c
index 058512d..bc563ca 100644
--- a/src/core/soft_uart.c
+++ b/src/core/soft_uart.c
@@ -136,6 +136,9 @@
                                suart->rx.flow_state = SUART_FLOW_ST_PARITY;
                        else
                                suart->rx.flow_state = SUART_FLOW_ST_STOP;
+                       /* align the register if needed */
+                       if (suart->cfg.num_data_bits < 8)
+                               suart->rx.shift_reg >>= (8 - 
suart->cfg.num_data_bits);
                }
                break;
        case SUART_FLOW_ST_PARITY:
diff --git a/tests/soft_uart/soft_uart_test.ok 
b/tests/soft_uart/soft_uart_test.ok
index e670a0e..118c547 100644
--- a/tests/soft_uart/soft_uart_test.ok
+++ b/tests/soft_uart/soft_uart_test.ok
@@ -128,16 +128,16 @@
 test_tx_rx_exec_one(n_bits_total=44): 11111111111 11111111111 11111111111 
11111111111
 ======== test_tx_rx(): testing 6-N-1
 suart_tx_cb(len=4/4): de ad be ef
-suart_rx_cb(flags=00): 78 b4 f8 bc
+suart_rx_cb(flags=00): 1e 2d 3e 2f
 test_tx_rx_exec_one(n_bits_total=32): 00111101 01011011 00111111 01111011
 suart_tx_cb(len=4/4): 00 aa 55 ff
-suart_rx_cb(flags=00): 00 a8 54 fc
+suart_rx_cb(flags=00): 00 2a 15 3f
 test_tx_rx_exec_one(n_bits_total=32): 00000001 00101011 01010101 01111111
 suart_tx_cb(len=4/4): 01 02 04 08
-suart_rx_cb(flags=00): 04 08 10 20
+suart_rx_cb(flags=00): 01 02 04 08
 test_tx_rx_exec_one(n_bits_total=32): 01000001 00100001 00010001 00001001
 suart_tx_cb(len=4/4): 10 20 40 80
-suart_rx_cb(flags=00): 40 80 00 00
+suart_rx_cb(flags=00): 10 20 00 00
 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

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35066?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: Ife13b1f2d9063ba7253d01523ca9ecb15e9eaf07
Gerrit-Change-Number: 35066
Gerrit-PatchSet: 5
Gerrit-Owner: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: jolly <andr...@eversberg.eu>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to