mirror of
https://github.com/espressif/openthread.git
synced 2026-10-02 05:47:40 +00:00
[posix-app] timeout for rcp radio driver (#3749)
This commit is contained in:
committed by
Jonathan Hui
parent
c972c5cb93
commit
f5ee3a5e65
@@ -55,6 +55,10 @@
|
|||||||
#include <openthread/platform/diag.h>
|
#include <openthread/platform/diag.h>
|
||||||
#include <openthread/platform/radio.h>
|
#include <openthread/platform/radio.h>
|
||||||
|
|
||||||
|
#ifndef TX_WAIT_US
|
||||||
|
#define TX_WAIT_US (5 * US_PER_S)
|
||||||
|
#endif
|
||||||
|
|
||||||
static ot::PosixApp::RadioSpinel sRadioSpinel;
|
static ot::PosixApp::RadioSpinel sRadioSpinel;
|
||||||
|
|
||||||
namespace ot {
|
namespace ot {
|
||||||
@@ -176,6 +180,7 @@ RadioSpinel::RadioSpinel(void)
|
|||||||
, mDiagOutput(NULL)
|
, mDiagOutput(NULL)
|
||||||
, mDiagOutputMaxLen(0)
|
, mDiagOutputMaxLen(0)
|
||||||
#endif
|
#endif
|
||||||
|
, mTxRadioEndUs(UINT64_MAX)
|
||||||
{
|
{
|
||||||
mVersion[0] = '\0';
|
mVersion[0] = '\0';
|
||||||
}
|
}
|
||||||
@@ -704,6 +709,26 @@ void RadioSpinel::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMax
|
|||||||
{
|
{
|
||||||
FD_SET(sockFd, &aWriteFdSet);
|
FD_SET(sockFd, &aWriteFdSet);
|
||||||
}
|
}
|
||||||
|
else if (mState == kStateTransmitting)
|
||||||
|
{
|
||||||
|
uint64_t now = otSysGetTime();
|
||||||
|
|
||||||
|
if (now < mTxRadioEndUs)
|
||||||
|
{
|
||||||
|
uint64_t remain = mTxRadioEndUs - now;
|
||||||
|
|
||||||
|
if (remain < static_cast<uint64_t>(aTimeout.tv_sec * US_PER_S + aTimeout.tv_usec))
|
||||||
|
{
|
||||||
|
aTimeout.tv_sec = static_cast<time_t>(remain / US_PER_S);
|
||||||
|
aTimeout.tv_usec = static_cast<suseconds_t>(remain % US_PER_S);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aTimeout.tv_sec = 0;
|
||||||
|
aTimeout.tv_usec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mHdlcInterface.GetRxFrameBuffer().HasSavedFrame() || (mState == kStateTransmitDone))
|
if (mHdlcInterface.GetRxFrameBuffer().HasSavedFrame() || (mState == kStateTransmitDone))
|
||||||
{
|
{
|
||||||
@@ -730,7 +755,8 @@ void RadioSpinel::Process(const fd_set &aReadFdSet, const fd_set &aWriteFdSet)
|
|||||||
|
|
||||||
if (mState == kStateTransmitDone)
|
if (mState == kStateTransmitDone)
|
||||||
{
|
{
|
||||||
mState = kStateReceive;
|
mState = kStateReceive;
|
||||||
|
mTxRadioEndUs = UINT64_MAX;
|
||||||
|
|
||||||
#if OPENTHREAD_ENABLE_DIAG
|
#if OPENTHREAD_ENABLE_DIAG
|
||||||
if (otPlatDiagModeGet())
|
if (otPlatDiagModeGet())
|
||||||
@@ -744,6 +770,11 @@ void RadioSpinel::Process(const fd_set &aReadFdSet, const fd_set &aWriteFdSet)
|
|||||||
mTxError);
|
mTxError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (mState == kStateTransmitting && otSysGetTime() >= mTxRadioEndUs)
|
||||||
|
{
|
||||||
|
otLogCritPlat("radio tx timeout, exit");
|
||||||
|
exit(OT_EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (FD_ISSET(mHdlcInterface.GetSocket(), &aWriteFdSet))
|
if (FD_ISSET(mHdlcInterface.GetSocket(), &aWriteFdSet))
|
||||||
{
|
{
|
||||||
@@ -1075,7 +1106,8 @@ void RadioSpinel::RadioTransmit(void)
|
|||||||
|
|
||||||
if (error == OT_ERROR_NONE)
|
if (error == OT_ERROR_NONE)
|
||||||
{
|
{
|
||||||
mState = kStateTransmitting;
|
mTxRadioEndUs = otSysGetTime() + TX_WAIT_US;
|
||||||
|
mState = kStateTransmitting;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -622,6 +622,8 @@ private:
|
|||||||
char * mDiagOutput;
|
char * mDiagOutput;
|
||||||
size_t mDiagOutputMaxLen;
|
size_t mDiagOutputMaxLen;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint64_t mTxRadioEndUs;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace PosixApp
|
} // namespace PosixApp
|
||||||
|
|||||||
Reference in New Issue
Block a user