mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 10:27:49 +00:00
[posix-app] allow pseudo reset (#4184)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user