[posix-app] allow pseudo reset (#4184)

This commit is contained in:
huamenggg
2019-09-18 07:47:30 -07:00
committed by Jonathan Hui
parent 6d1981b112
commit 1ac791b79d
2 changed files with 9 additions and 0 deletions
+3
View File
@@ -51,6 +51,7 @@
#include <common/code_utils.hpp>
#include <common/encoding.hpp>
#include <common/logging.hpp>
#include <common/new.hpp>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include <openthread/platform/radio.h>
@@ -308,6 +309,8 @@ exit:
void RadioSpinel::Deinit(void)
{
mHdlcInterface.Deinit();
// This allows implementing pseudo reset.
new (this) RadioSpinel();
}
void RadioSpinel::HandleSpinelFrame(HdlcInterface::RxFrameBuffer &aFrameBuffer)
+6
View File
@@ -67,6 +67,9 @@ otError otPlatUartEnable(void)
struct sockaddr_un sockname;
int ret;
// This allows implementing pseudo reset.
otEXPECT(sUartSocket == -1);
sUartSocket = SocketWithCloseExec(AF_UNIX, SOCK_STREAM, 0);
if (sUartSocket == -1)
@@ -109,6 +112,8 @@ otError otPlatUartEnable(void)
{
DieNowWithMessage("listen", OT_EXIT_ERROR_ERRNO);
}
exit:
#endif // OPENTHREAD_ENABLE_POSIX_APP_DAEMON
sEnabled = true;
@@ -135,6 +140,7 @@ otError otPlatUartDisable(void)
if (sUartLock != -1)
{
(void)flock(sUartLock, LOCK_UN);
close(sUartLock);
sUartLock = -1;
}