diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2023-11-18 01:46:16 +0700 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2023-11-21 20:17:11 +0700 |
commit | bf95f822914ac0fb1c177d82da698f21a7ae5cc9 (patch) | |
tree | a31d484a6473d206cb1faaee39fac867e1403a07 /src | |
parent | 9ef304dd25d76ccb3d85292a364b43af880251cd (diff) |
soft_uart: fix Rx buffer flushing logic in suart_rx_ch()
Whenever we encounter a parity and/or a framing error, we should
call the .rx_cb() immediately, even if this was the first
character in the receive buffer.
Change-Id: I73fab1a5c196d2dbdfe98b0c20d8dadbd22f4f64
Related: OS#4396
Diffstat (limited to 'src')
-rw-r--r-- | src/core/soft_uart.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c index 400ce5ac..058512d1 100644 --- a/src/core/soft_uart.c +++ b/src/core/soft_uart.c @@ -97,12 +97,13 @@ static void suart_rx_ch(struct osmo_soft_uart *suart, uint8_t ch) msgb_put_u8(suart->rx.msg, ch); msg_len = msgb_length(suart->rx.msg); - /* first character in new message: start timer */ - if (msg_len == 1) { + if (msg_len >= suart->cfg.rx_buf_size || suart->rx.flags) { + /* either the buffer is full, or we hit a parity and/or a framing error */ + osmo_soft_uart_flush_rx(suart); + } else if (msg_len == 1) { + /* first character in new message: start timer */ osmo_timer_schedule(&suart->rx.timer, suart->cfg.rx_timeout_ms / 1000, (suart->cfg.rx_timeout_ms % 1000) * 1000); - } else if (msg_len >= suart->cfg.rx_buf_size || suart->rx.flags) { - osmo_soft_uart_flush_rx(suart); } } |