Skip to content

Commit 3470934

Browse files
authored
[diag] remove redundant messages output by the diag module (openthread#11118)
1 parent b6a7f07 commit 3470934

File tree

8 files changed

+60
-119
lines changed

8 files changed

+60
-119
lines changed

src/core/diags/README.md

+10-22
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Start diagnostics mode.
3737

3838
```bash
3939
> diag start
40-
start diagnostics mode
4140
Done
4241
```
4342

@@ -47,7 +46,7 @@ Get the IEEE 802.15.4 Channel value for diagnostics module.
4746

4847
```bash
4948
> diag channel
50-
channel: 11
49+
11
5150
Done
5251
```
5352

@@ -57,7 +56,6 @@ Set the IEEE 802.15.4 Channel value for diagnostics module.
5756

5857
```bash
5958
> diag channel 11
60-
set channel to 11
6159
Done
6260
```
6361

@@ -123,7 +121,7 @@ Get the tx power value(dBm) for diagnostics module.
123121

124122
```bash
125123
> diag power
126-
tx power: -10 dBm
124+
-10
127125
Done
128126
```
129127

@@ -133,7 +131,6 @@ Set the tx power value(dBm) for diagnostics module.
133131

134132
```bash
135133
> diag power -10
136-
set tx power to -10 dBm
137134
Done
138135
```
139136

@@ -170,23 +167,27 @@ Done
170167

171168
Transmit a fixed number of packets.
172169

173-
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]).
170+
- packets: The number of packets to be sent.
171+
- length: The length of packet. The valid range is [3, 127].
172+
173+
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.
174174

175175
```bash
176176
> diag send 20 100
177-
sending 0x14 packet(s), length 0x64
178177
Done
179178
```
180179

181180
### diag repeat \<delay\> [length]
182181

183182
Transmit packets repeatedly with a fixed interval.
184183

185-
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]).
184+
- delay: The interval between two consecutive packets in milliseconds.
185+
- length: The length of packet. The valid range is [3, 127].
186+
187+
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.
186188

187189
```bash
188190
> diag repeat 100 100
189-
sending packets of length 0x64 at the delay of 0x64 ms
190191
Done
191192
```
192193

@@ -196,7 +197,6 @@ Stop repeated packet transmission.
196197

197198
```bash
198199
> diag repeat stop
199-
repeated packet transmission is stopped
200200
Done
201201
```
202202

@@ -206,7 +206,6 @@ Enter radio sleep mode.
206206

207207
```bash
208208
> diag radio sleep
209-
set radio from receive to sleep
210209
Done
211210
```
212211

@@ -216,7 +215,6 @@ Set radio from sleep mode to receive mode.
216215

217216
```bash
218217
> diag radio receive
219-
set radio from sleep to receive on channel 11
220218
Done
221219
```
222220

@@ -360,7 +358,6 @@ Clear statistics during diagnostics mode.
360358

361359
```bash
362360
> diag stats clear
363-
stats cleared
364361
Done
365362
```
366363

@@ -419,15 +416,6 @@ Stop diagnostics mode and print statistics.
419416

420417
```bash
421418
> diag stop
422-
received packets: 10
423-
sent success packets: 10
424-
sent error cca packets: 0
425-
sent error abort packets: 0
426-
sent error others packets: 0
427-
first received packet: rssi=-65, lqi=101
428-
last received packet: rssi=-61, lqi=98
429-
430-
stop diagnostics mode
431419
Done
432420
```
433421

src/core/diags/factory_diags.cpp

+2-27
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Error Diags::ProcessChannel(uint8_t aArgsLength, char *aArgs[])
332332

333333
if (aArgsLength == 0)
334334
{
335-
Output("channel: %d\r\n", mChannel);
335+
Output("%u\r\n", mChannel);
336336
}
337337
else
338338
{
@@ -344,8 +344,6 @@ Error Diags::ProcessChannel(uint8_t aArgsLength, char *aArgs[])
344344
mChannel = channel;
345345
IgnoreError(Get<Radio>().Receive(mChannel));
346346
otPlatDiagChannelSet(mChannel);
347-
348-
Output("set channel to %d\r\n", mChannel);
349347
}
350348

351349
exit:
@@ -358,7 +356,7 @@ Error Diags::ProcessPower(uint8_t aArgsLength, char *aArgs[])
358356

359357
if (aArgsLength == 0)
360358
{
361-
Output("tx power: %d dBm\r\n", mTxPower);
359+
Output("%d\r\n", mTxPower);
362360
}
363361
else
364362
{
@@ -369,8 +367,6 @@ Error Diags::ProcessPower(uint8_t aArgsLength, char *aArgs[])
369367
mTxPower = txPower;
370368
SuccessOrExit(error = Get<Radio>().SetTransmitPower(mTxPower));
371369
otPlatDiagTxPowerSet(mTxPower);
372-
373-
Output("set tx power to %d dBm\r\n", mTxPower);
374370
}
375371

376372
exit:
@@ -387,7 +383,6 @@ Error Diags::ProcessRepeat(uint8_t aArgsLength, char *aArgs[])
387383
{
388384
otPlatAlarmMilliStop(&GetInstance());
389385
mRepeatActive = false;
390-
Output("repeated packet transmission is stopped\r\n");
391386
}
392387
else
393388
{
@@ -420,8 +415,6 @@ Error Diags::ProcessRepeat(uint8_t aArgsLength, char *aArgs[])
420415
mRepeatActive = true;
421416
uint32_t now = otPlatAlarmMilliGetNow();
422417
otPlatAlarmMilliStartAt(&GetInstance(), now, mTxPeriod);
423-
Output("sending packets of length %#x at the delay of %#x ms\r\n", static_cast<int>(mTxLen),
424-
static_cast<int>(mTxPeriod));
425418
}
426419

427420
exit:
@@ -457,7 +450,6 @@ Error Diags::ProcessSend(uint8_t aArgsLength, char *aArgs[])
457450
VerifyOrExit(txLength >= OT_RADIO_FRAME_MIN_SIZE, error = kErrorInvalidArgs);
458451
mTxLen = txLength;
459452

460-
Output("sending %#x packet(s), length %#x\r\n", static_cast<int>(mTxPackets), static_cast<int>(mTxLen));
461453
TransmitPacket();
462454

463455
exit:
@@ -486,7 +478,6 @@ Error Diags::ProcessStart(uint8_t aArgsLength, char *aArgs[])
486478
SuccessOrExit(error = Get<Radio>().SetTransmitPower(mTxPower));
487479
otPlatDiagModeSet(true);
488480
mStats.Clear();
489-
Output("start diagnostics mode\r\n");
490481

491482
exit:
492483
return error;
@@ -513,7 +504,6 @@ Error Diags::ProcessStats(uint8_t aArgsLength, char *aArgs[])
513504
if ((aArgsLength == 1) && StringMatch(aArgs[0], "clear"))
514505
{
515506
mStats.Clear();
516-
Output("stats cleared\r\n");
517507
}
518508
else
519509
{
@@ -535,9 +525,6 @@ Error Diags::ProcessStop(uint8_t aArgsLength, char *aArgs[])
535525
Get<Radio>().SetPromiscuous(false);
536526
Get<Mac::SubMac>().SetRxOnWhenIdle(false);
537527

538-
OutputStats();
539-
Output("\nstop diagnostics mode\r\n");
540-
541528
return kErrorNone;
542529
}
543530

@@ -619,7 +606,6 @@ Error Diags::ProcessRadio(uint8_t aArgsLength, char *aArgs[])
619606
if (StringMatch(aArgs[0], "sleep"))
620607
{
621608
SuccessOrExit(error = Get<Radio>().Sleep());
622-
Output("set radio from receive to sleep \r\n");
623609
}
624610
else if (StringMatch(aArgs[0], "receive"))
625611
{
@@ -631,7 +617,6 @@ Error Diags::ProcessRadio(uint8_t aArgsLength, char *aArgs[])
631617
if (aArgsLength == 0)
632618
{
633619
SuccessOrExit(error = RadioReceive());
634-
Output("set radio from sleep to receive on channel %d\r\n", mChannel);
635620
ExitNow();
636621
}
637622

@@ -1074,14 +1059,6 @@ Error Diags::ProcessGpio(uint8_t aArgsLength, char *aArgs[])
10741059
return error;
10751060
}
10761061

1077-
void Diags::AppendErrorResult(Error aError)
1078-
{
1079-
if ((aError != kErrorNone) && (aError != kErrorPending))
1080-
{
1081-
Output("failed\r\nstatus %#x\r\n", aError);
1082-
}
1083-
}
1084-
10851062
bool Diags::IsChannelValid(uint8_t aChannel)
10861063
{
10871064
return (aChannel >= Radio::kChannelMin && aChannel <= Radio::kChannelMax);
@@ -1183,8 +1160,6 @@ Error Diags::ProcessCmd(uint8_t aArgsLength, char *aArgs[])
11831160
Output("diag feature '%s' is not supported\r\n", aArgs[0]);
11841161
}
11851162

1186-
AppendErrorResult(error);
1187-
11881163
return error;
11891164
}
11901165

src/core/diags/factory_diags.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ class Diags : public InstanceLocator, private NonCopyable
237237

238238
void TransmitPacket(void);
239239
void Output(const char *aFormat, ...);
240-
void AppendErrorResult(Error aError);
241240
void ResetTxPacket(void);
242241
void OutputStats(void);
243242

tests/scripts/expect/cli-diags.exp

-23
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,26 @@ spawn_node 2
3535

3636
switch_node 1
3737
send "diag start\n"
38-
expect "start diagnostics mode"
3938
expect_line "Done"
4039

4140
send "diag channel 11\n"
42-
expect "set channel to 11"
4341
expect_line "Done"
4442

4543
send "diag stats clear\n"
46-
expect "stats cleared"
4744
expect_line "Done"
4845

4946
switch_node 2
5047

5148
send "diag start\n"
52-
expect "start diagnostics mode"
5349
expect_line "Done"
5450

5551
send "diag channel 11\n"
56-
expect "set channel to 11"
5752
expect_line "Done"
5853

5954
send "diag stats clear\n"
60-
expect "stats cleared"
6155
expect_line "Done"
6256

6357
send "diag send 10 100\n"
64-
expect "sending 0xa packet(s), length 0x64"
6558
expect_line "Done"
6659

6760
sleep 2
@@ -89,17 +82,14 @@ expect "last received packet: rssi=-20, lqi=0"
8982
expect_line "Done"
9083

9184
send "diag stats clear\n"
92-
expect "stats cleared"
9385
expect_line "Done"
9486

9587
switch_node 2
9688

9789
send "diag repeat 20 100\n"
98-
expect "sending packets of length 0x64 at the delay of 0x14 ms"
9990
expect_line "Done"
10091
sleep 1
10192
send "diag repeat stop\n"
102-
expect "repeated packet transmission is stopped"
10393
expect_line "Done"
10494

10595
switch_node 1
@@ -115,7 +105,6 @@ expect "last received packet: rssi=-20, lqi=0"
115105
expect_line "Done"
116106

117107
send "diag stats clear\n"
118-
expect "stats cleared"
119108
expect_line "Done"
120109

121110
dispose_all
@@ -124,7 +113,6 @@ dispose_all
124113
spawn_node 1
125114

126115
send "diag start\n"
127-
expect "start diagnostics mode"
128116
expect_line "Done"
129117

130118
send_user "input too short test\n"
@@ -143,58 +131,49 @@ send_user "shortest frame test\n"
143131
send "diag frame 112233\n"
144132
expect "Done"
145133
send "diag send 1\n"
146-
expect "length 0x3"
147134
expect "Done"
148135

149136
send_user "longest frame test\n"
150137
send "diag frame 11223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677\n"
151138
expect "Done"
152139
send "diag repeat 1\n"
153-
expect "length 0x7f"
154140
expect "Done"
155141

156142
send_user "send frame with security processed\n"
157143
send "diag frame -s 112233\n"
158144
expect "Done"
159145
send "diag send 1\n"
160-
expect "length 0x3"
161146
expect "Done"
162147

163148
send_user "send frame with CSMA/CA enabled\n"
164149
send "diag frame -c 112233\n"
165150
expect "Done"
166151
send "diag send 1\n"
167-
expect "length 0x3"
168152
expect "Done"
169153

170154
send_user "send frame with tx power\n"
171155
send "diag frame -p 11 112233\n"
172156
expect "Done"
173157
send "diag send 1\n"
174-
expect "length 0x3"
175158
expect "Done"
176159

177160
send "diag repeat stop\n"
178161
expect "Done"
179162

180163
send "diag channel 11\n"
181-
expect "set channel to 11"
182164
expect_line "Done"
183165

184166
send "diag power 10\n"
185-
expect "set tx power to 10 dBm"
186167
expect_line "Done"
187168

188169
send "diag radio sleep\n"
189-
expect "set radio from receive to sleep"
190170
expect_line "Done"
191171

192172
send "diag radio state\n"
193173
expect "sleep"
194174
expect_line "Done"
195175

196176
send "diag radio receive\n"
197-
expect "set radio from sleep to receive on channel 11"
198177
expect_line "Done"
199178

200179
send "diag radio state\n"
@@ -254,8 +233,6 @@ send "diag stop\n"
254233
expect_line "Done"
255234

256235
send "diag channel\n"
257-
expect "failed"
258-
expect "status 0xd"
259236
expect "Error 13: InvalidState"
260237

261238
dispose_all

0 commit comments

Comments
 (0)