From 501a190546f7c790956d0cca20faeed8a7a914c3 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Thu, 21 Nov 2019 13:12:23 +0800 Subject: [PATCH] [posix-app] remove function "HdlcInterface::IsDecoding()" (#4340) The function "RadioSpinel::IsSafeToHandleNow()" is finally called by the function "HdlcInterface::Decode()". However, the variable "mIsDecoding" is set to TRUE before calling "RadioSpinel::IsSafeToHandleNow()" in function "HdlcInterface::Decode()". So the function "IsDecoding()" always return TURE in function "RadioSpinel::IsSafeToHandleNow()". This commit removes the function "IsDecoding()" to simplify the code. --- src/posix/platform/hdlc_interface.cpp | 3 --- src/posix/platform/hdlc_interface.hpp | 8 -------- src/posix/platform/radio_spinel.hpp | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index df05cd81e..944503912 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -125,7 +125,6 @@ namespace PosixApp { HdlcInterface::HdlcInterface(Callbacks &aCallbacks) : mCallbacks(aCallbacks) , mSockFd(-1) - , mIsDecoding(false) , mRxFrameBuffer() , mHdlcDecoder(mRxFrameBuffer, HandleHdlcFrame, this) { @@ -199,9 +198,7 @@ void HdlcInterface::Read(void) void HdlcInterface::Decode(const uint8_t *aBuffer, uint16_t aLength) { - mIsDecoding = true; mHdlcDecoder.Decode(aBuffer, aLength); - mIsDecoding = false; } otError HdlcInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) diff --git a/src/posix/platform/hdlc_interface.hpp b/src/posix/platform/hdlc_interface.hpp index c3416ee0d..fe95a81dd 100644 --- a/src/posix/platform/hdlc_interface.hpp +++ b/src/posix/platform/hdlc_interface.hpp @@ -129,14 +129,6 @@ public: */ int GetSocket(void) const { return mSockFd; } - /** - * This method indicates whether the `HdclInterface` is currently decoding a received frame or not. - * - * @returns TRUE if currently decoding a received frame, FALSE otherwise. - * - */ - bool IsDecoding(void) const { return mIsDecoding; } - /** * This method instructs `HdlcInterface` to read and decode data from radio over the socket. * diff --git a/src/posix/platform/radio_spinel.hpp b/src/posix/platform/radio_spinel.hpp index aecb096b4..95bd20ad9 100644 --- a/src/posix/platform/radio_spinel.hpp +++ b/src/posix/platform/radio_spinel.hpp @@ -627,7 +627,7 @@ private: */ bool IsSafeToHandleNow(spinel_prop_key_t aKey) const { - return !((mHdlcInterface.IsDecoding() || mWaitingKey != SPINEL_PROP_LAST_STATUS) && + return !((mWaitingKey != SPINEL_PROP_LAST_STATUS) && (aKey == SPINEL_PROP_STREAM_RAW || aKey == SPINEL_PROP_MAC_ENERGY_SCAN_RESULT)); }