mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 11:19:51 +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/radio.h>
|
||||
|
||||
#ifndef TX_WAIT_US
|
||||
#define TX_WAIT_US (5 * US_PER_S)
|
||||
#endif
|
||||
|
||||
static ot::PosixApp::RadioSpinel sRadioSpinel;
|
||||
|
||||
namespace ot {
|
||||
@@ -176,6 +180,7 @@ RadioSpinel::RadioSpinel(void)
|
||||
, mDiagOutput(NULL)
|
||||
, mDiagOutputMaxLen(0)
|
||||
#endif
|
||||
, mTxRadioEndUs(UINT64_MAX)
|
||||
{
|
||||
mVersion[0] = '\0';
|
||||
}
|
||||
@@ -704,6 +709,26 @@ void RadioSpinel::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMax
|
||||
{
|
||||
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))
|
||||
{
|
||||
@@ -730,7 +755,8 @@ void RadioSpinel::Process(const fd_set &aReadFdSet, const fd_set &aWriteFdSet)
|
||||
|
||||
if (mState == kStateTransmitDone)
|
||||
{
|
||||
mState = kStateReceive;
|
||||
mState = kStateReceive;
|
||||
mTxRadioEndUs = UINT64_MAX;
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
if (otPlatDiagModeGet())
|
||||
@@ -744,6 +770,11 @@ void RadioSpinel::Process(const fd_set &aReadFdSet, const fd_set &aWriteFdSet)
|
||||
mTxError);
|
||||
}
|
||||
}
|
||||
else if (mState == kStateTransmitting && otSysGetTime() >= mTxRadioEndUs)
|
||||
{
|
||||
otLogCritPlat("radio tx timeout, exit");
|
||||
exit(OT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (FD_ISSET(mHdlcInterface.GetSocket(), &aWriteFdSet))
|
||||
{
|
||||
@@ -1075,7 +1106,8 @@ void RadioSpinel::RadioTransmit(void)
|
||||
|
||||
if (error == OT_ERROR_NONE)
|
||||
{
|
||||
mState = kStateTransmitting;
|
||||
mTxRadioEndUs = otSysGetTime() + TX_WAIT_US;
|
||||
mState = kStateTransmitting;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -622,6 +622,8 @@ private:
|
||||
char * mDiagOutput;
|
||||
size_t mDiagOutputMaxLen;
|
||||
#endif
|
||||
|
||||
uint64_t mTxRadioEndUs;
|
||||
};
|
||||
|
||||
} // namespace PosixApp
|
||||
|
||||
Reference in New Issue
Block a user