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-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 40start diagnostics mode 41status 0x00 42``` 43 44### diag channel 45 46Get the IEEE 802.15.4 Channel value for diagnostics module. 47 48```bash 49> diag channel 50channel: 11 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 59set channel to 11 60status 0x00 61``` 62 63### diag cw start 64 65Start transmitting continuous carrier wave. 66 67```bash 68> diag cw start 69Done 70``` 71 72### diag cw stop 73 74Stop transmitting continuous carrier wave. 75 76```bash 77> diag cw stop 78Done 79``` 80 81### diag frame 82 83Usage: `diag frame [-s] <frame>` 84 85Set the frame (hex encoded) to be used by `diag send` and `diag repeat`. The frame may be overwritten by `diag send` and `diag repeat`. 86 87Specify `-s` to skip security processing in radio layer. 88 89```bash 90> diag frame 11223344 91Done 92``` 93 94### diag stream start 95 96Start transmitting a stream of characters. 97 98```bash 99> diag stream start 100Done 101``` 102 103### diag stream stop 104 105Stop transmitting a stream of characters. 106 107```bash 108> diag stream stop 109Done 110``` 111 112### diag power 113 114Get the tx power value(dBm) for diagnostics module. 115 116```bash 117> diag power 118tx power: -10 dBm 119``` 120 121### diag power \<power\> 122 123Set the tx power value(dBm) for diagnostics module. 124 125```bash 126> diag power -10 127set tx power to -10 dBm 128status 0x00 129``` 130 131### diag powersettings 132 133Show the currently used power settings table. 134 135- Note: The unit of `TargetPower` and `ActualPower` is 0.01dBm. 136 137```bash 138> diag powersettings 139| StartCh | EndCh | TargetPower | ActualPower | RawPowerSetting | 140+---------+-------+-------------+-------------+-----------------+ 141| 11 | 14 | 1700 | 1000 | 223344 | 142| 15 | 24 | 2000 | 1900 | 112233 | 143| 25 | 25 | 1600 | 1000 | 223344 | 144| 26 | 26 | 1600 | 1500 | 334455 | 145Done 146``` 147 148### diag powersettings \<channel\> 149 150Show the currently used power settings for the given channel. 151 152```bash 153> diag powersettings 11 154TargetPower(0.01dBm): 1700 155ActualPower(0.01dBm): 1000 156RawPowerSetting: 223344 157Done 158``` 159 160### diag send \<packets\> [length] 161 162Transmit a fixed number of packets. 163 164Send 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]). 165 166```bash 167> diag send 20 100 168sending 0x14 packet(s), length 0x64 169status 0x00 170``` 171 172### diag repeat \<delay\> [length] 173 174Transmit packets repeatedly with a fixed interval. 175 176Send 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]). 177 178```bash 179> diag repeat 100 100 180sending packets of length 0x64 at the delay of 0x64 ms 181status 0x00 182``` 183 184### diag repeat stop 185 186Stop repeated packet transmission. 187 188```bash 189> diag repeat stop 190repeated packet transmission is stopped 191status 0x00 192``` 193 194### diag radio sleep 195 196Enter radio sleep mode. 197 198```bash 199> diag radio sleep 200set radio from receive to sleep 201status 0x00 202``` 203 204### diag radio receive 205 206Set radio from sleep mode to receive mode. 207 208```bash 209> diag radio receive 210set radio from sleep to receive on channel 11 211status 0x00 212``` 213 214### diag radio state 215 216Return the state of the radio. 217 218```bash 219> diag radio state 220sleep 221``` 222 223### diag rawpowersetting 224 225Show the raw power setting for diagnostics module. 226 227```bash 228> diag rawpowersetting 229112233 230Done 231``` 232 233### diag rawpowersetting \<settings\> 234 235Set the raw power setting for diagnostics module. 236 237```bash 238> diag rawpowersetting 112233 239Done 240``` 241 242### diag rawpowersetting enable 243 244Enable the platform layer to use the value set by the command `diag rawpowersetting \<settings\>`. 245 246```bash 247> diag rawpowersetting enable 248Done 249``` 250 251### diag rawpowersetting disable 252 253Disable the platform layer to use the value set by the command `diag rawpowersetting \<settings\>`. 254 255```bash 256> diag rawpowersetting disable 257Done 258``` 259 260### diag stats 261 262Print statistics during diagnostics mode. 263 264```bash 265> diag stats 266received packets: 10 267sent packets: 10 268first received packet: rssi=-65, lqi=101 269last received packet: rssi=-64, lqi=98 270``` 271 272### diag stats clear 273 274Clear statistics during diagnostics mode. 275 276```bash 277> diag stats clear 278stats cleared 279``` 280 281### diag gpio get \<gpio\> 282 283Get the gpio value. 284 285```bash 286> diag gpio get 0 2871 288Done 289``` 290 291### diag gpio set \<gpio\> \<value\> 292 293Set the gpio value. 294 295The parameter `value` has to be `0` or `1`. 296 297```bash 298> diag gpio set 0 1 299Done 300``` 301 302### diag gpio mode \<gpio\> 303 304Get the gpio mode. 305 306```bash 307> diag gpio mode 1 308in 309Done 310``` 311 312### diag gpio mode \<gpio\> in 313 314Sets the given gpio to the input mode without pull resistor. 315 316```bash 317> diag gpio mode 1 in 318Done 319``` 320 321### diag gpio mode \<gpio\> out 322 323Sets the given gpio to the output mode. 324 325```bash 326> diag gpio mode 1 out 327Done 328``` 329 330### diag stop 331 332Stop diagnostics mode and print statistics. 333 334```bash 335> diag stop 336received packets: 10 337sent packets: 10 338first received packet: rssi=-65, lqi=101 339last received packet: rssi=-61, lqi=98 340 341stop diagnostics mode 342status 0x00 343``` 344 345### diag rcp 346 347RCP-related diagnostics commands. These commands are used for debugging and testing only. 348 349#### diag rcp start 350 351Start RCP diagnostics mode. 352 353```bash 354> diag rcp start 355Done 356``` 357 358#### diag rcp stop 359 360Stop RCP diagnostics mode. 361 362```bash 363> diag rcp stop 364Done 365``` 366 367#### diag rcp channel \<channel\> 368 369Set the RCP IEEE 802.15.4 Channel value for diagnostics module. 370 371```bash 372> diag rcp channel 11 373Done 374``` 375 376#### diag rcp power \<power\> 377 378Set the RCP tx power value(dBm) for diagnostics module. 379 380```bash 381> diag rcp power 0 382Done 383``` 384 385#### diag rcp echo \<message\> 386 387RCP echoes the given message. 388 389```bash 390> diag rcp echo 0123456789 3910123456789 392Done 393``` 394 395#### diag rcp echo -n \<number\> 396 397RCP echoes the message with the given number of bytes. 398 399```bash 400> diag rcp echo -n 20 40101234567890123456789 402Done 403``` 404