diff --git a/src/cli/README.md b/src/cli/README.md index 7b308c1ef..d34ae33fd 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -20,6 +20,7 @@ OpenThread test scripts use the CLI to execute test cases. * [counters](#counters) * [dataset](README_DATASET.md) * [delaytimermin](#delaytimermin) +* [diag](#diag) * [discover](#discover-channel) * [dns](#dns-resolve-hostname-dns-server-ip-dns-server-port) * [eidcache](#eidcache) @@ -65,14 +66,13 @@ OpenThread test scripts use the CLI to execute test cases. * [routerselectionjitter](#routerselectionjitter) * [routerupgradethreshold](#routerupgradethreshold) * [scan](#scan-channel) +* [service](#service) * [singleton](#singleton) * [sntp](#sntp-query-sntp-server-ip-sntp-server-port) * [state](#state) * [thread](#thread-start) * [txpower](#txpower) * [version](#version) -* [diag](#diag) -* [service](#service) ## OpenThread Command Details diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 4705d41a5..6061209ec 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -91,7 +91,6 @@ namespace ot { namespace Cli { const struct Command Interpreter::sCommands[] = { - {"help", &Interpreter::ProcessHelp}, {"bufferinfo", &Interpreter::ProcessBufferInfo}, {"channel", &Interpreter::ProcessChannel}, #if OPENTHREAD_FTD @@ -140,6 +139,7 @@ const struct Command Interpreter::sCommands[] = { {"extaddr", &Interpreter::ProcessExtAddress}, {"extpanid", &Interpreter::ProcessExtPanId}, {"factoryreset", &Interpreter::ProcessFactoryReset}, + {"help", &Interpreter::ProcessHelp}, {"ifconfig", &Interpreter::ProcessIfconfig}, {"ipaddr", &Interpreter::ProcessIpAddr}, {"ipmaddr", &Interpreter::ProcessIpMulticastAddr}, diff --git a/src/core/diags/factory_diags.cpp b/src/core/diags/factory_diags.cpp index 03ba1d7c1..0297c01c6 100644 --- a/src/core/diags/factory_diags.cpp +++ b/src/core/diags/factory_diags.cpp @@ -74,8 +74,7 @@ void Diags::ProcessChannel(int aArgCount, char *aArgVector[], char *aOutput, siz SuccessOrExit(error = ParseLong(aArgVector[0], value)); VerifyOrExit(value >= Radio::kChannelMin && value <= Radio::kChannelMax, error = OT_ERROR_INVALID_ARGS); - mChannel = static_cast(value); - otPlatDiagChannelSet(mChannel); + otPlatDiagChannelSet(static_cast(value)); exit: AppendErrorResult(error, aOutput, aOutputMaxLen); @@ -90,8 +89,7 @@ void Diags::ProcessPower(int aArgCount, char *aArgVector[], char *aOutput, size_ SuccessOrExit(error = ParseLong(aArgVector[0], value)); - mTxPower = static_cast(value); - otPlatDiagTxPowerSet(mTxPower); + otPlatDiagTxPowerSet(static_cast(value)); exit: AppendErrorResult(error, aOutput, aOutputMaxLen); @@ -132,12 +130,12 @@ const struct Diags::Command Diags::sCommands[] = { Diags::Diags(Instance &aInstance) : InstanceLocator(aInstance) - , mTxPower(0) - , mChannel(20) - , mTxLen(0) + , mTxPacket(&Get().GetTransmitBuffer()) , mTxPeriod(0) , mTxPackets(0) - , mTxPacket(&Get().GetTransmitBuffer()) + , mChannel(20) + , mTxPower(0) + , mTxLen(0) , mRepeatActive(false) { memset(&mStats, 0, sizeof(mStats)); diff --git a/src/core/diags/factory_diags.hpp b/src/core/diags/factory_diags.hpp index c3343663b..f10310ce2 100644 --- a/src/core/diags/factory_diags.hpp +++ b/src/core/diags/factory_diags.hpp @@ -145,15 +145,18 @@ private: static otError ParseLong(char *aString, long &aLong); static const struct Command sCommands[]; - struct Stats mStats; - int8_t mTxPower; - uint8_t mChannel; - uint8_t mTxLen; +#if !OPENTHREAD_RADIO + struct Stats mStats; + + otRadioFrame *mTxPacket; uint32_t mTxPeriod; uint32_t mTxPackets; - otRadioFrame *mTxPacket; + uint8_t mChannel; + int8_t mTxPower; + uint8_t mTxLen; bool mRepeatActive; +#endif }; #endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/tests/scripts/thread-cert/test_diag.py b/tests/scripts/thread-cert/test_diag.py index b72ce25b5..2303952a2 100755 --- a/tests/scripts/thread-cert/test_diag.py +++ b/tests/scripts/thread-cert/test_diag.py @@ -51,6 +51,8 @@ class TestDiag(unittest.TestCase): 'failed\r\nstatus 0xd\r\n'), ('diag start\n', 'start diagnostics mode\r\nstatus 0x00\r\n'), + ('diag invalid test\n', + 'diag feature \'invalid\' is not supported'), ('diag', 'diagnostics mode is enabled\r\n'), ('diag channel 10\n',