Skip to content

Commit

Permalink
[diag] Refactor command processing to remove redundant code
Browse files Browse the repository at this point in the history
All diagnostic commands (instead of `diag start`) should fail if
device is not in diagnostic mode. Previously it was verified by
each command's process method (with a missing check in
`ProcessEcho` and `ProcessGpio`). This commit moves the check
directly to `ProcessCmd` and cleans up redundant code.

Additionally clean the documentation and align the code as for
some commands `status 0x00` was added on success and for some not.

Move `AppendErrorResult()` to `ProcessCmd()` as well.

Signed-off-by: Maciej Baczmanski <[email protected]>
  • Loading branch information
maciejbaczmanski committed Dec 17, 2024
1 parent 971f05f commit 8a3f7a8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 100 deletions.
41 changes: 14 additions & 27 deletions src/core/diags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Start diagnostics mode.
```bash
> diag start
start diagnostics mode
status 0x00
Done
```

### diag channel
Expand All @@ -48,6 +48,7 @@ Get the IEEE 802.15.4 Channel value for diagnostics module.
```bash
> diag channel
channel: 11
Done
```

### diag channel \<channel\>
Expand All @@ -57,7 +58,7 @@ Set the IEEE 802.15.4 Channel value for diagnostics module.
```bash
> diag channel 11
set channel to 11
status 0x00
Done
```

### diag cw start
Expand Down Expand Up @@ -123,6 +124,7 @@ Get the tx power value(dBm) for diagnostics module.
```bash
> diag power
tx power: -10 dBm
Done
```

### diag power \<power\>
Expand All @@ -132,7 +134,7 @@ Set the tx power value(dBm) for diagnostics module.
```bash
> diag power -10
set tx power to -10 dBm
status 0x00
Done
```

### diag powersettings
Expand Down Expand Up @@ -173,7 +175,7 @@ Send the frame set by `diag frame` if length is omitted. Otherwise overwrite the
```bash
> diag send 20 100
sending 0x14 packet(s), length 0x64
status 0x00
Done
```

### diag repeat \<delay\> [length]
Expand All @@ -185,7 +187,7 @@ Send the frame set by `diag frame` if length is omitted. Otherwise overwrite the
```bash
> diag repeat 100 100
sending packets of length 0x64 at the delay of 0x64 ms
status 0x00
Done
```

### diag repeat stop
Expand All @@ -195,7 +197,7 @@ Stop repeated packet transmission.
```bash
> diag repeat stop
repeated packet transmission is stopped
status 0x00
Done
```

### diag radio sleep
Expand All @@ -205,7 +207,7 @@ Enter radio sleep mode.
```bash
> diag radio sleep
set radio from receive to sleep
status 0x00
Done
```

### diag radio receive
Expand All @@ -215,7 +217,7 @@ Set radio from sleep mode to receive mode.
```bash
> diag radio receive
set radio from sleep to receive on channel 11
status 0x00
Done
```

### diag radio receive \[async\] \<number\> \[lpr\]
Expand Down Expand Up @@ -245,6 +247,7 @@ Return the state of the radio.
```bash
> diag radio state
sleep
Done
```

### diag radio enable
Expand Down Expand Up @@ -312,6 +315,7 @@ received packets: 10
sent packets: 10
first received packet: rssi=-65, lqi=101
last received packet: rssi=-64, lqi=98
Done
```

### diag stats clear
Expand All @@ -321,6 +325,7 @@ Clear statistics during diagnostics mode.
```bash
> diag stats clear
stats cleared
Done
```

### diag gpio get \<gpio\>
Expand Down Expand Up @@ -384,31 +389,13 @@ first received packet: rssi=-65, lqi=101
last received packet: rssi=-61, lqi=98

stop diagnostics mode
status 0x00
Done
```

### diag rcp

RCP-related diagnostics commands. These commands are used for debugging and testing only.

#### diag rcp start

Start RCP diagnostics mode.

```bash
> diag rcp start
Done
```

#### diag rcp stop

Stop RCP diagnostics mode.

```bash
> diag rcp stop
Done
```

#### diag rcp channel \<channel\>

Set the RCP IEEE 802.15.4 Channel value for diagnostics module.
Expand Down
Loading

0 comments on commit 8a3f7a8

Please sign in to comment.