From 36f4f43adc55ef3ed411001915fd10d078c15721 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 28 Aug 2017 21:16:38 -0700 Subject: [PATCH] [ncp-uart] fix the bug in uart encoder (#2145) This commit fixes an issue with the `NcpUart::EncodeAndSendToUart()` code where the last message can be removed from `mTxFrameBuffer` and if we ran out of buffer and cannot finalize the HDLC encoded frame, the final bytes would not be sent until next message is queued in `mTxBuffer`. --- src/ncp/ncp_uart.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ncp/ncp_uart.cpp b/src/ncp/ncp_uart.cpp index ef3089e1e..e75c596bc 100644 --- a/src/ncp/ncp_uart.cpp +++ b/src/ncp/ncp_uart.cpp @@ -137,7 +137,7 @@ void NcpUart::EncodeAndSendToUart(void) { uint16_t len; - while (!mTxFrameBuffer.IsEmpty()) + while (!mTxFrameBuffer.IsEmpty() || (mState == kFinalizingFrame)) { switch (mState) { @@ -159,7 +159,7 @@ void NcpUart::EncodeAndSendToUart(void) { mByte = mTxFrameBuffer.OutFrameReadByte(); - case kEncodingFrame: + case kEncodingFrame: SuccessOrExit(mFrameEncoder.Encode(mByte, mUartBuffer)); }