[diag] clean up unnecessary variables and code (#4102)

This commit is contained in:
Yakun Xu
2019-08-22 08:38:56 -07:00
committed by Jonathan Hui
parent 27cac08e8a
commit 79c61a5700
5 changed files with 19 additions and 16 deletions
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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},
+6 -8
View File
@@ -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<uint8_t>(value);
otPlatDiagChannelSet(mChannel);
otPlatDiagChannelSet(static_cast<uint8_t>(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<int8_t>(value);
otPlatDiagTxPowerSet(mTxPower);
otPlatDiagTxPowerSet(static_cast<int8_t>(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<Radio>().GetTransmitBuffer())
, mTxPeriod(0)
, mTxPackets(0)
, mTxPacket(&Get<Radio>().GetTransmitBuffer())
, mChannel(20)
, mTxPower(0)
, mTxLen(0)
, mRepeatActive(false)
{
memset(&mStats, 0, sizeof(mStats));
+8 -5
View File
@@ -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
+2
View File
@@ -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',