1# OpenThread Factory Diagnostics Module Reference
2
3The OpenThread diagnostics module is a tool for debugging platform hardware manually, and it will also be used during manufacturing process, to verify platform hardware performance.
4
5The diagnostics module supports common diagnostics features that are listed below, and it also provides a mechanism for expanding platform specific diagnostics features.
6
7## Common Diagnostics Command List
8
9- [diag](#diag)
10- [diag start](#diag-start)
11- [diag channel](#diag-channel)
12- [diag cw](#diag-cw-start)
13- [diag frame](#diag-frame)
14- [diag stream](#diag-stream-start)
15- [diag power](#diag-power)
16- [diag powersettings](#diag-powersettings)
17- [diag send](#diag-send-async-packets-length)
18- [diag repeat](#diag-repeat-delay-length)
19- [diag radio](#diag-radio-sleep)
20- [diag rawpowersetting](#diag-rawpowersetting)
21- [diag stats](#diag-stats)
22- [diag gpio](#diag-gpio-get-gpio)
23- [diag stop](#diag-stop)
24
25### diag
26
27Show diagnostics mode status.
28
29```bash
30> diag
31diagnostics mode is disabled
32```
33
34### diag start
35
36Start diagnostics mode.
37
38```bash
39> diag start
40Done
41```
42
43### diag channel
44
45Get the IEEE 802.15.4 Channel value for diagnostics module.
46
47```bash
48> diag channel
4911
50Done
51```
52
53### diag channel \<channel\>
54
55Set the IEEE 802.15.4 Channel value for diagnostics module.
56
57```bash
58> diag channel 11
59Done
60```
61
62### diag cw start
63
64Start transmitting continuous carrier wave.
65
66```bash
67> diag cw start
68Done
69```
70
71### diag cw stop
72
73Stop transmitting continuous carrier wave.
74
75```bash
76> diag cw stop
77Done
78```
79
80### diag frame
81
82Usage: `diag frame [-b MaxCsmaBackoffs] [-c] [-C RxChannelAfterTxDone] [-d TxDelay] [-p TxPower] [-r MaxFrameRetries] [-s] [-u] <frame>`
83
84Set the frame (hex encoded) to be used by `diag send` and `diag repeat`. The frame may be overwritten by `diag send` and `diag repeat`.
85
86- Specify `-b` to specify the `mInfo.mTxInfo.mMaxCsmaBackoffs` field for this frame.
87- Specify `-c` to enable CSMA/CA for this frame in the radio layer.
88- Specify `-C` to specify the `mInfo.mTxInfo.mRxChannelAfterTxDone` field for this frame.
89- Specify `-d` to specify the `mInfo.mTxInfo.mTxDelay` field for this frame and the `mInfo.mTxInfo.mTxDelayBaseTime` field is set to the current radio time.
90- Specify `-p` to specify the tx power in dBm for this frame.
91- Specify `-r` to specify the `mInfo.mTxInfo.mMaxFrameRetries` field for this frame.
92- Specify `-s` to indicate that tx security is already processed thus it should be skipped in the radio layer.
93- Specify `-u` to specify the `mInfo.mTxInfo.mIsHeaderUpdated` field for this frame.
94
95```bash
96> diag frame 11223344
97Done
98```
99
100### diag stream start
101
102Start transmitting a stream of characters.
103
104```bash
105> diag stream start
106Done
107```
108
109### diag stream stop
110
111Stop transmitting a stream of characters.
112
113```bash
114> diag stream stop
115Done
116```
117
118### diag power
119
120Get the tx power value(dBm) for diagnostics module.
121
122```bash
123> diag power
124-10
125Done
126```
127
128### diag power \<power\>
129
130Set the tx power value(dBm) for diagnostics module.
131
132```bash
133> diag power -10
134Done
135```
136
137### diag powersettings
138
139Show the currently used power settings table.
140
141- Note: The unit of `TargetPower` and `ActualPower` is 0.01dBm.
142
143```bash
144> diag powersettings
145| StartCh | EndCh | TargetPower | ActualPower | RawPowerSetting |
146+---------+-------+-------------+-------------+-----------------+
147|      11 |    14 |        1700 |        1000 |          223344 |
148|      15 |    24 |        2000 |        1900 |          112233 |
149|      25 |    25 |        1600 |        1000 |          223344 |
150|      26 |    26 |        1600 |        1500 |          334455 |
151Done
152```
153
154### diag powersettings \<channel\>
155
156Show the currently used power settings for the given channel.
157
158```bash
159> diag powersettings 11
160TargetPower(0.01dBm): 1700
161ActualPower(0.01dBm): 1000
162RawPowerSetting: 223344
163Done
164```
165
166### diag send [async] \<packets\> [length]
167
168Transmit a fixed number of packets.
169
170- async: Use the non-blocking mode.
171- packets: The number of packets to be sent.
172- length: The length of packet. The valid range is [3, 127].
173
174Send 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.
175
176```bash
177> diag send 20 100
178Done
179> diag send async 20 100
180Done
181```
182
183### diag repeat \<delay\> [length]
184
185Transmit packets repeatedly with a fixed interval.
186
187- delay: The interval between two consecutive packets in milliseconds.
188- length: The length of packet. The valid range is [3, 127].
189
190Send 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.
191
192```bash
193> diag repeat 100 100
194Done
195```
196
197### diag repeat stop
198
199Stop repeated packet transmission.
200
201```bash
202> diag repeat stop
203Done
204```
205
206### diag radio sleep
207
208Enter radio sleep mode.
209
210```bash
211> diag radio sleep
212Done
213```
214
215### diag radio receive
216
217Set radio from sleep mode to receive mode.
218
219```bash
220> diag radio receive
221Done
222```
223
224### diag radio receive \[async\] \<number\> \[lpr\]
225
226Set the radio to receive mode and receive a specified number of frames.
227
228- async: Use the non-blocking mode.
229- number: The number of frames expected to be received.
230- l: Show Lqi.
231- p: Show Psdu.
232- r: Show Rssi.
233
234```bash
235> diag radio receive 5 lpr
2360, rssi:-49, lqi:119, len:10, psdu:000102030405060771e
2371, rssi:-51, lqi:112, len:10, psdu:000102030405060771e
2382, rssi:-42, lqi:120, len:10, psdu:000102030405060771e
2393, rssi:-54, lqi:111, len:10, psdu:000102030405060771e
2404, rssi:-56, lqi:108, len:10, psdu:000102030405060771e
241Done
242```
243
244### diag radio receive filter enable
245
246Enable the diag filter module to only receive frames with a specified destination address.
247
248```bash
249> diag radio receive filter enable
250Done
251```
252
253### diag radio receive filter disable
254
255Disable the diag filter module from only receiving frames with a specified destination address.
256
257```bash
258> diag radio receive filter disable
259Done
260```
261
262### diag radio receive filter \<destaddress\>
263
264Set the destination address of the radio receive filter.
265
266- destaddress: The destination mac address. It can be a short, extended or none. Use '-' to specify none.
267
268```bash
269> diag radio receive filter -
270Done
271> diag radio receive filter 0x0a17
272Done
273> diag radio receive filter dead00beef00cafe
274Done
275```
276
277### diag radio state
278
279Return the state of the radio.
280
281```bash
282> diag radio state
283sleep
284Done
285```
286
287### diag radio enable
288
289Enable radio interface and put it in receive mode.
290
291```bash
292> diag radio enable
293Done
294```
295
296### diag radio disable
297
298Disable radio interface.
299
300```bash
301> diag radio disable
302Done
303```
304
305### diag rawpowersetting
306
307Show the raw power setting for diagnostics module.
308
309```bash
310> diag rawpowersetting
311112233
312Done
313```
314
315### diag rawpowersetting \<settings\>
316
317Set the raw power setting for diagnostics module.
318
319```bash
320> diag rawpowersetting 112233
321Done
322```
323
324### diag rawpowersetting enable
325
326Enable the platform layer to use the value set by the command `diag rawpowersetting \<settings\>`.
327
328```bash
329> diag rawpowersetting enable
330Done
331```
332
333### diag rawpowersetting disable
334
335Disable the platform layer to use the value set by the command `diag rawpowersetting \<settings\>`.
336
337```bash
338> diag rawpowersetting disable
339Done
340```
341
342### diag stats
343
344Print statistics during diagnostics mode.
345
346```bash
347> diag stats
348received packets: 10
349sent success packets: 10
350sent error cca packets: 0
351sent error abort packets: 0
352sent error invalid state packets: 0
353sent error others packets: 0
354first received packet: rssi=-65, lqi=101
355last received packet: rssi=-64, lqi=98
356Done
357```
358
359### diag stats clear
360
361Clear statistics during diagnostics mode.
362
363```bash
364> diag stats clear
365Done
366```
367
368### diag gpio get \<gpio\>
369
370Get the gpio value.
371
372```bash
373> diag gpio get 0
3741
375Done
376```
377
378### diag gpio set \<gpio\> \<value\>
379
380Set the gpio value.
381
382The parameter `value` has to be `0` or `1`.
383
384```bash
385> diag gpio set 0 1
386Done
387```
388
389### diag gpio mode \<gpio\>
390
391Get the gpio mode.
392
393```bash
394> diag gpio mode 1
395in
396Done
397```
398
399### diag gpio mode \<gpio\> in
400
401Sets the given gpio to the input mode without pull resistor.
402
403```bash
404> diag gpio mode 1 in
405Done
406```
407
408### diag gpio mode \<gpio\> out
409
410Sets the given gpio to the output mode.
411
412```bash
413> diag gpio mode 1 out
414Done
415```
416
417### diag stop
418
419Stop diagnostics mode and print statistics.
420
421```bash
422> diag stop
423Done
424```
425
426### diag rcp
427
428RCP-related diagnostics commands. These commands are used for debugging and testing only.
429
430#### diag rcp start
431
432Start RCP diagnostics mode.
433
434```bash
435> diag rcp start
436Done
437```
438
439#### diag rcp stop
440
441Stop RCP diagnostics mode.
442
443```bash
444> diag rcp stop
445Done
446```
447
448#### diag rcp channel \<channel\>
449
450Set the RCP IEEE 802.15.4 Channel value for diagnostics module.
451
452```bash
453> diag rcp channel 11
454Done
455```
456
457#### diag rcp power \<power\>
458
459Set the RCP tx power value(dBm) for diagnostics module.
460
461```bash
462> diag rcp power 0
463Done
464```
465
466#### diag rcp echo \<message\>
467
468RCP echoes the given message.
469
470```bash
471> diag rcp echo 0123456789
4720123456789
473Done
474```
475
476#### diag rcp echo -n \<number\>
477
478RCP echoes the message with the given number of bytes.
479
480```bash
481> diag rcp echo -n 20
48201234567890123456789
483Done
484```
485