mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 11:17:46 +00:00
[diag] remove redundant messages output by the diag module (#11118)
This commit is contained in:
+10
-22
@@ -37,7 +37,6 @@ Start diagnostics mode.
|
||||
|
||||
```bash
|
||||
> diag start
|
||||
start diagnostics mode
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -47,7 +46,7 @@ Get the IEEE 802.15.4 Channel value for diagnostics module.
|
||||
|
||||
```bash
|
||||
> diag channel
|
||||
channel: 11
|
||||
11
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -57,7 +56,6 @@ Set the IEEE 802.15.4 Channel value for diagnostics module.
|
||||
|
||||
```bash
|
||||
> diag channel 11
|
||||
set channel to 11
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -123,7 +121,7 @@ Get the tx power value(dBm) for diagnostics module.
|
||||
|
||||
```bash
|
||||
> diag power
|
||||
tx power: -10 dBm
|
||||
-10
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -133,7 +131,6 @@ Set the tx power value(dBm) for diagnostics module.
|
||||
|
||||
```bash
|
||||
> diag power -10
|
||||
set tx power to -10 dBm
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -170,11 +167,13 @@ Done
|
||||
|
||||
Transmit a fixed number of packets.
|
||||
|
||||
Send the frame set by `diag frame` if length is omitted. Otherwise overwrite the frame set by `diag frame` and send a frame of the given length(MUST be in range [3, 127]).
|
||||
- packets: The number of packets to be sent.
|
||||
- length: The length of packet. The valid range is [3, 127].
|
||||
|
||||
Send the frame set by `diag frame` if length is omitted. Otherwise overwrite the frame set by `diag frame` and send a frame of the given length.
|
||||
|
||||
```bash
|
||||
> diag send 20 100
|
||||
sending 0x14 packet(s), length 0x64
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -182,11 +181,13 @@ Done
|
||||
|
||||
Transmit packets repeatedly with a fixed interval.
|
||||
|
||||
Send the frame set by `diag frame` if length is omitted. Otherwise overwrite the frame set by `diag frame` and send a frame of the given length (MUST be in range [3, 127]).
|
||||
- delay: The interval between two consecutive packets in milliseconds.
|
||||
- length: The length of packet. The valid range is [3, 127].
|
||||
|
||||
Send the frame set by `diag frame` if length is omitted. Otherwise overwrite the frame set by `diag frame` and send a frame of the given length.
|
||||
|
||||
```bash
|
||||
> diag repeat 100 100
|
||||
sending packets of length 0x64 at the delay of 0x64 ms
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -196,7 +197,6 @@ Stop repeated packet transmission.
|
||||
|
||||
```bash
|
||||
> diag repeat stop
|
||||
repeated packet transmission is stopped
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -206,7 +206,6 @@ Enter radio sleep mode.
|
||||
|
||||
```bash
|
||||
> diag radio sleep
|
||||
set radio from receive to sleep
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -216,7 +215,6 @@ Set radio from sleep mode to receive mode.
|
||||
|
||||
```bash
|
||||
> diag radio receive
|
||||
set radio from sleep to receive on channel 11
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -360,7 +358,6 @@ Clear statistics during diagnostics mode.
|
||||
|
||||
```bash
|
||||
> diag stats clear
|
||||
stats cleared
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -419,15 +416,6 @@ Stop diagnostics mode and print statistics.
|
||||
|
||||
```bash
|
||||
> diag stop
|
||||
received packets: 10
|
||||
sent success packets: 10
|
||||
sent error cca packets: 0
|
||||
sent error abort packets: 0
|
||||
sent error others packets: 0
|
||||
first received packet: rssi=-65, lqi=101
|
||||
last received packet: rssi=-61, lqi=98
|
||||
|
||||
stop diagnostics mode
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ Error Diags::ProcessChannel(uint8_t aArgsLength, char *aArgs[])
|
||||
|
||||
if (aArgsLength == 0)
|
||||
{
|
||||
Output("channel: %d\r\n", mChannel);
|
||||
Output("%u\r\n", mChannel);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -344,8 +344,6 @@ Error Diags::ProcessChannel(uint8_t aArgsLength, char *aArgs[])
|
||||
mChannel = channel;
|
||||
IgnoreError(Get<Radio>().Receive(mChannel));
|
||||
otPlatDiagChannelSet(mChannel);
|
||||
|
||||
Output("set channel to %d\r\n", mChannel);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -358,7 +356,7 @@ Error Diags::ProcessPower(uint8_t aArgsLength, char *aArgs[])
|
||||
|
||||
if (aArgsLength == 0)
|
||||
{
|
||||
Output("tx power: %d dBm\r\n", mTxPower);
|
||||
Output("%d\r\n", mTxPower);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -369,8 +367,6 @@ Error Diags::ProcessPower(uint8_t aArgsLength, char *aArgs[])
|
||||
mTxPower = txPower;
|
||||
SuccessOrExit(error = Get<Radio>().SetTransmitPower(mTxPower));
|
||||
otPlatDiagTxPowerSet(mTxPower);
|
||||
|
||||
Output("set tx power to %d dBm\r\n", mTxPower);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -387,7 +383,6 @@ Error Diags::ProcessRepeat(uint8_t aArgsLength, char *aArgs[])
|
||||
{
|
||||
otPlatAlarmMilliStop(&GetInstance());
|
||||
mRepeatActive = false;
|
||||
Output("repeated packet transmission is stopped\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -420,8 +415,6 @@ Error Diags::ProcessRepeat(uint8_t aArgsLength, char *aArgs[])
|
||||
mRepeatActive = true;
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
otPlatAlarmMilliStartAt(&GetInstance(), now, mTxPeriod);
|
||||
Output("sending packets of length %#x at the delay of %#x ms\r\n", static_cast<int>(mTxLen),
|
||||
static_cast<int>(mTxPeriod));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -457,7 +450,6 @@ Error Diags::ProcessSend(uint8_t aArgsLength, char *aArgs[])
|
||||
VerifyOrExit(txLength >= OT_RADIO_FRAME_MIN_SIZE, error = kErrorInvalidArgs);
|
||||
mTxLen = txLength;
|
||||
|
||||
Output("sending %#x packet(s), length %#x\r\n", static_cast<int>(mTxPackets), static_cast<int>(mTxLen));
|
||||
TransmitPacket();
|
||||
|
||||
exit:
|
||||
@@ -486,7 +478,6 @@ Error Diags::ProcessStart(uint8_t aArgsLength, char *aArgs[])
|
||||
SuccessOrExit(error = Get<Radio>().SetTransmitPower(mTxPower));
|
||||
otPlatDiagModeSet(true);
|
||||
mStats.Clear();
|
||||
Output("start diagnostics mode\r\n");
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -513,7 +504,6 @@ Error Diags::ProcessStats(uint8_t aArgsLength, char *aArgs[])
|
||||
if ((aArgsLength == 1) && StringMatch(aArgs[0], "clear"))
|
||||
{
|
||||
mStats.Clear();
|
||||
Output("stats cleared\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -535,9 +525,6 @@ Error Diags::ProcessStop(uint8_t aArgsLength, char *aArgs[])
|
||||
Get<Radio>().SetPromiscuous(false);
|
||||
Get<Mac::SubMac>().SetRxOnWhenIdle(false);
|
||||
|
||||
OutputStats();
|
||||
Output("\nstop diagnostics mode\r\n");
|
||||
|
||||
return kErrorNone;
|
||||
}
|
||||
|
||||
@@ -619,7 +606,6 @@ Error Diags::ProcessRadio(uint8_t aArgsLength, char *aArgs[])
|
||||
if (StringMatch(aArgs[0], "sleep"))
|
||||
{
|
||||
SuccessOrExit(error = Get<Radio>().Sleep());
|
||||
Output("set radio from receive to sleep \r\n");
|
||||
}
|
||||
else if (StringMatch(aArgs[0], "receive"))
|
||||
{
|
||||
@@ -631,7 +617,6 @@ Error Diags::ProcessRadio(uint8_t aArgsLength, char *aArgs[])
|
||||
if (aArgsLength == 0)
|
||||
{
|
||||
SuccessOrExit(error = RadioReceive());
|
||||
Output("set radio from sleep to receive on channel %d\r\n", mChannel);
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
@@ -1074,14 +1059,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void Diags::AppendErrorResult(Error aError)
|
||||
{
|
||||
if ((aError != kErrorNone) && (aError != kErrorPending))
|
||||
{
|
||||
Output("failed\r\nstatus %#x\r\n", aError);
|
||||
}
|
||||
}
|
||||
|
||||
bool Diags::IsChannelValid(uint8_t aChannel)
|
||||
{
|
||||
return (aChannel >= Radio::kChannelMin && aChannel <= Radio::kChannelMax);
|
||||
@@ -1183,8 +1160,6 @@ exit:
|
||||
Output("diag feature '%s' is not supported\r\n", aArgs[0]);
|
||||
}
|
||||
|
||||
AppendErrorResult(error);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,6 @@ private:
|
||||
|
||||
void TransmitPacket(void);
|
||||
void Output(const char *aFormat, ...);
|
||||
void AppendErrorResult(Error aError);
|
||||
void ResetTxPacket(void);
|
||||
void OutputStats(void);
|
||||
|
||||
|
||||
@@ -35,33 +35,26 @@ spawn_node 2
|
||||
|
||||
switch_node 1
|
||||
send "diag start\n"
|
||||
expect "start diagnostics mode"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag channel 11\n"
|
||||
expect "set channel to 11"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag stats clear\n"
|
||||
expect "stats cleared"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 2
|
||||
|
||||
send "diag start\n"
|
||||
expect "start diagnostics mode"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag channel 11\n"
|
||||
expect "set channel to 11"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag stats clear\n"
|
||||
expect "stats cleared"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag send 10 100\n"
|
||||
expect "sending 0xa packet(s), length 0x64"
|
||||
expect_line "Done"
|
||||
|
||||
sleep 2
|
||||
@@ -89,17 +82,14 @@ expect "last received packet: rssi=-20, lqi=0"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag stats clear\n"
|
||||
expect "stats cleared"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 2
|
||||
|
||||
send "diag repeat 20 100\n"
|
||||
expect "sending packets of length 0x64 at the delay of 0x14 ms"
|
||||
expect_line "Done"
|
||||
sleep 1
|
||||
send "diag repeat stop\n"
|
||||
expect "repeated packet transmission is stopped"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 1
|
||||
@@ -115,7 +105,6 @@ expect "last received packet: rssi=-20, lqi=0"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag stats clear\n"
|
||||
expect "stats cleared"
|
||||
expect_line "Done"
|
||||
|
||||
dispose_all
|
||||
@@ -124,7 +113,6 @@ dispose_all
|
||||
spawn_node 1
|
||||
|
||||
send "diag start\n"
|
||||
expect "start diagnostics mode"
|
||||
expect_line "Done"
|
||||
|
||||
send_user "input too short test\n"
|
||||
@@ -143,50 +131,42 @@ send_user "shortest frame test\n"
|
||||
send "diag frame 112233\n"
|
||||
expect "Done"
|
||||
send "diag send 1\n"
|
||||
expect "length 0x3"
|
||||
expect "Done"
|
||||
|
||||
send_user "longest frame test\n"
|
||||
send "diag frame 11223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677\n"
|
||||
expect "Done"
|
||||
send "diag repeat 1\n"
|
||||
expect "length 0x7f"
|
||||
expect "Done"
|
||||
|
||||
send_user "send frame with security processed\n"
|
||||
send "diag frame -s 112233\n"
|
||||
expect "Done"
|
||||
send "diag send 1\n"
|
||||
expect "length 0x3"
|
||||
expect "Done"
|
||||
|
||||
send_user "send frame with CSMA/CA enabled\n"
|
||||
send "diag frame -c 112233\n"
|
||||
expect "Done"
|
||||
send "diag send 1\n"
|
||||
expect "length 0x3"
|
||||
expect "Done"
|
||||
|
||||
send_user "send frame with tx power\n"
|
||||
send "diag frame -p 11 112233\n"
|
||||
expect "Done"
|
||||
send "diag send 1\n"
|
||||
expect "length 0x3"
|
||||
expect "Done"
|
||||
|
||||
send "diag repeat stop\n"
|
||||
expect "Done"
|
||||
|
||||
send "diag channel 11\n"
|
||||
expect "set channel to 11"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag power 10\n"
|
||||
expect "set tx power to 10 dBm"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag radio sleep\n"
|
||||
expect "set radio from receive to sleep"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag radio state\n"
|
||||
@@ -194,7 +174,6 @@ expect "sleep"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag radio receive\n"
|
||||
expect "set radio from sleep to receive on channel 11"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag radio state\n"
|
||||
@@ -254,8 +233,6 @@ send "diag stop\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag channel\n"
|
||||
expect "failed"
|
||||
expect "status 0xd"
|
||||
expect "Error 13: InvalidState"
|
||||
|
||||
dispose_all
|
||||
|
||||
@@ -33,11 +33,8 @@ spawn_node 1
|
||||
|
||||
send "diag rcp\n"
|
||||
expect "diagnostics mode is disabled"
|
||||
expect_line "failed"
|
||||
expect_line "status 0xd"
|
||||
expect_line "Error 13: InvalidState"
|
||||
send "diag start\n"
|
||||
expect "start diagnostics mode"
|
||||
expect_line "Done"
|
||||
send "diag rcp\n"
|
||||
expect "diagnostics mode is enabled"
|
||||
|
||||
@@ -32,12 +32,9 @@ source "tests/scripts/expect/_common.exp"
|
||||
spawn_node 1
|
||||
|
||||
send "diag start\n"
|
||||
expect "start diagnostics mode"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag powersettings 11\n"
|
||||
expect "failed"
|
||||
expect "status 0x17"
|
||||
expect_line "Error 23: NotFound"
|
||||
|
||||
send "diag powersettings\n"
|
||||
@@ -52,7 +49,6 @@ send "region US\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag start\n"
|
||||
expect "start diagnostics mode"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag powersettings 11\n"
|
||||
|
||||
@@ -47,11 +47,11 @@ class TestDiag(thread_cert.TestCase):
|
||||
('diag start', 'Done\r\n'),
|
||||
('diag invalid test\n', 'diag feature \'invalid\' is not supported'),
|
||||
('diag', 'diagnostics mode is enabled\r\n'),
|
||||
('diag channel 10', 'failed\r\nstatus 0x7\r\n'),
|
||||
('diag channel 11', 'set channel to 11\r\n'),
|
||||
('diag channel', 'channel: 11\r\n'),
|
||||
('diag power -10', 'set tx power to -10 dBm\r\n'),
|
||||
('diag power', 'tx power: -10 dBm\r\n'),
|
||||
('diag channel 10', 'Error 7: InvalidArgs\r\n'),
|
||||
('diag channel 11', 'Done\r\n'),
|
||||
('diag channel', '11\r\n'),
|
||||
('diag power -10', 'Done\r\n'),
|
||||
('diag power', '-10\r\n'),
|
||||
(
|
||||
'diag stats',
|
||||
'received packets: 0\r\n'
|
||||
@@ -62,37 +62,15 @@ class TestDiag(thread_cert.TestCase):
|
||||
'first received packet: rssi=0, lqi=0\r\n'
|
||||
'last received packet: rssi=0, lqi=0\r\n',
|
||||
),
|
||||
(
|
||||
'diag send 20 100',
|
||||
r'sending 0x14 packet\(s\), length 0x64\r\n',
|
||||
),
|
||||
(
|
||||
' diag \t send \t 20\t100',
|
||||
r'sending 0x14 packet\(s\), length 0x64\r\n',
|
||||
),
|
||||
(
|
||||
'diag repeat 100 100',
|
||||
'sending packets of length 0x64 at the delay of 0x64 ms\r\n',
|
||||
),
|
||||
(
|
||||
'diag repeat stop',
|
||||
'repeated packet transmission is stopped\r\n',
|
||||
),
|
||||
(
|
||||
'diag stop',
|
||||
'received packets: 0\r\n'
|
||||
r'sent success packets: ([1-9]\d*)\r\n'
|
||||
r'sent error cca packets: ([0-9]\d*)\r\n'
|
||||
r'sent error abort packets: ([0-9]\d*)\r\n'
|
||||
r'sent error others packets: ([0-9]\d*)\r\n'
|
||||
'first received packet: rssi=0, lqi=0\r\n'
|
||||
'last received packet: rssi=0, lqi=0\r\n\n'
|
||||
r'stop diagnostics mode\r\n',
|
||||
),
|
||||
('diag send 20 100', 'Done\r\n'),
|
||||
(' diag \t send \t 20\t100', 'Done\r\n'),
|
||||
('diag repeat 100 100', 'Done\r\n'),
|
||||
('diag repeat stop', 'Done\r\n'),
|
||||
('diag stop', 'Done\r\n'),
|
||||
('diag', 'diagnostics mode is disabled\r\n'),
|
||||
(
|
||||
'diag 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32',
|
||||
r'Error 7: InvalidArgs\r\n',
|
||||
'Error 7: InvalidArgs\r\n',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
+37
-6
@@ -2528,7 +2528,7 @@ class OTCI(object):
|
||||
def diag_get_channel(self) -> int:
|
||||
"""Get the IEEE 802.15.4 Channel value for diagnostics module."""
|
||||
line = self.__parse_str(self.execute_command('diag channel'))
|
||||
return int(line.split()[1])
|
||||
return int(line)
|
||||
|
||||
def diag_set_power(self, power: int):
|
||||
"""Set the tx power value(dBm) for diagnostics module."""
|
||||
@@ -2537,10 +2537,7 @@ class OTCI(object):
|
||||
def diag_get_power(self) -> int:
|
||||
"""Get the tx power value(dBm) for diagnostics module."""
|
||||
line = self.__parse_str(self.execute_command('diag power'))
|
||||
if not line.endswith(' dBm'):
|
||||
raise UnexpectedCommandOutput([line])
|
||||
|
||||
return int(line.split()[2])
|
||||
return int(line)
|
||||
|
||||
def diag_cw_start(self):
|
||||
"""Start transmitting continuous carrier wave."""
|
||||
@@ -2672,8 +2669,21 @@ class OTCI(object):
|
||||
|
||||
def diag_get_stats(self) -> Dict[str, int]:
|
||||
"""Get statistics during diagnostics mode."""
|
||||
#
|
||||
# The command 'diag stats' output example:
|
||||
#
|
||||
# > diag stats
|
||||
# received packets: 10
|
||||
# sent success packets: 10
|
||||
# sent error cca packets: 0
|
||||
# sent error abort packets: 0
|
||||
# sent error others packets: 0
|
||||
# first received packet: rssi=-65, lqi=101
|
||||
# last received packet: rssi=-64, lqi=98
|
||||
# Done
|
||||
#
|
||||
output = self.execute_command('diag stats')
|
||||
if len(output) < 4:
|
||||
if len(output) < 7:
|
||||
raise UnexpectedCommandOutput(output)
|
||||
|
||||
result = {}
|
||||
@@ -2724,6 +2734,18 @@ class OTCI(object):
|
||||
|
||||
def diag_get_powersettings(self) -> List[Dict[str, Any]]:
|
||||
"""Get the currently used power settings table."""
|
||||
#
|
||||
# The command 'diag powersettings' output example:
|
||||
#
|
||||
# > diag powersettings
|
||||
# | StartCh | EndCh | TargetPower | ActualPower | RawPowerSetting |
|
||||
# +---------+-------+-------------+-------------+-----------------+
|
||||
# | 11 | 14 | 1700 | 1000 | 223344 |
|
||||
# | 15 | 24 | 2000 | 1900 | 112233 |
|
||||
# | 25 | 25 | 1600 | 1000 | 223344 |
|
||||
# | 26 | 26 | 1600 | 1500 | 334455 |
|
||||
# Done
|
||||
#
|
||||
result = []
|
||||
output = self.execute_command(f'diag powersettings')
|
||||
|
||||
@@ -2748,6 +2770,15 @@ class OTCI(object):
|
||||
|
||||
def diag_get_channel_powersettings(self, channel: int) -> Dict[str, Any]:
|
||||
"""Gets the currently used power settings for the given channel."""
|
||||
#
|
||||
# The command 'diag powersettings <channel>' output example:
|
||||
#
|
||||
# > diag powersettings 11
|
||||
# TargetPower(0.01dBm): 1700
|
||||
# ActualPower(0.01dBm): 1000
|
||||
# RawPowerSetting: 223344
|
||||
# Done
|
||||
#
|
||||
result = {}
|
||||
output = self.execute_command(f'diag powersettings {channel}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user