|
| 1 | +# CLI Commands |
| 2 | + |
| 3 | +The Smart Sensor Hub exposes a UART-based command-line interface (CLI) over the ST-LINK VCP (USART2). |
| 4 | +Default settings: **115200 baud, 8 data bits, no parity, 1 stop bit (115200 8N1)**. |
| 5 | + |
| 6 | +On reset you should see: |
| 7 | + |
| 8 | +```text |
| 9 | +Smart Sensor Hub CLI ready. |
| 10 | +Type 'help' for a list of commands. |
| 11 | +> |
| 12 | +``` |
| 13 | + |
| 14 | +You can then type commands followed by Enter. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## General Behavior |
| 19 | + |
| 20 | +- Input is **line-based**: the command is processed when you press Enter. |
| 21 | +- Backspace is supported. |
| 22 | +- Unknown commands generate a clear error message. |
| 23 | +- The CLI prompt is always kept at the bottom like a dashboard: |
| 24 | + - Log messages scroll above. |
| 25 | + - Prompt is redrawn after each log line. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## Command Reference |
| 30 | + |
| 31 | +### `help` |
| 32 | + |
| 33 | +**Usage:** |
| 34 | + |
| 35 | +```text |
| 36 | +> help |
| 37 | +``` |
| 38 | + |
| 39 | +**Description:** |
| 40 | +Lists all available commands with a short description. |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +### `log off` |
| 45 | + |
| 46 | +Disables all **task logging** (logs from `LOG_*` macros). |
| 47 | +CLI output remains active. |
| 48 | + |
| 49 | +```text |
| 50 | +> log off |
| 51 | +Task logging disabled. |
| 52 | +``` |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +### `log error` |
| 57 | + |
| 58 | +Enables task logging with **ERROR** level only. |
| 59 | + |
| 60 | +```text |
| 61 | +> log error |
| 62 | +Task logging enabled, level=ERROR. |
| 63 | +``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +### `log warn` |
| 68 | + |
| 69 | +Enables task logging with **WARN and ERROR** messages. |
| 70 | + |
| 71 | +```text |
| 72 | +> log warn |
| 73 | +Task logging enabled, level=WARN. |
| 74 | +``` |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +### `log info` |
| 79 | + |
| 80 | +Enables task logging with **INFO, WARN, and ERROR** messages. |
| 81 | + |
| 82 | +```text |
| 83 | +> log info |
| 84 | +Task logging enabled, level=INFO. |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +### `log debug` |
| 90 | + |
| 91 | +Enables task logging with **DEBUG, INFO, WARN, and ERROR** messages. |
| 92 | + |
| 93 | +```text |
| 94 | +> log debug |
| 95 | +Task logging enabled, level=DEBUG. |
| 96 | +``` |
| 97 | + |
| 98 | +This is the most verbose setting and is very useful while developing. |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +### `log pause` |
| 103 | + |
| 104 | +Temporarily **pauses task logging** while remembering the previous log level and enabled state. |
| 105 | + |
| 106 | +```text |
| 107 | +> log pause |
| 108 | +Task logging paused. Use 'log resume' to restore. |
| 109 | +``` |
| 110 | + |
| 111 | +Use this when you want to type or read CLI output without logs scrolling. |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +### `log resume` |
| 116 | + |
| 117 | +Restores the logging configuration saved by `log pause`. |
| 118 | + |
| 119 | +```text |
| 120 | +> log resume |
| 121 | +Task logging resumed. |
| 122 | +``` |
| 123 | + |
| 124 | +If logging was not paused, you see: |
| 125 | + |
| 126 | +```text |
| 127 | +Task logging is not paused. |
| 128 | +``` |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +### `pmode <mode>` |
| 133 | + |
| 134 | +Requests a change in the system **power mode**. |
| 135 | + |
| 136 | +Supported modes: |
| 137 | + |
| 138 | +- `active` |
| 139 | +- `idle` |
| 140 | +- `sleep` |
| 141 | +- `stop` |
| 142 | + |
| 143 | +**Example:** |
| 144 | + |
| 145 | +```text |
| 146 | +> pmode idle |
| 147 | +Requested power mode change: idle |
| 148 | +``` |
| 149 | + |
| 150 | +Currently (v0.4.0) the Power Manager: |
| 151 | + |
| 152 | +- Logs mode transitions. |
| 153 | +- Tracks idle cycles. |
| 154 | +- Drives the **sensor sampling period** used by the `SensorSample` task: |
| 155 | + - ACTIVE → 1000 ms |
| 156 | + - IDLE → 5000 ms |
| 157 | + - SLEEP → 30000 ms |
| 158 | + - STOP → 0 ms (no sampling) |
| 159 | + |
| 160 | +Future phases may map these modes to real STM32 low-power states. |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +### `status` |
| 165 | + |
| 166 | +Displays the current logging configuration, power mode, and effective sensor sample period. |
| 167 | + |
| 168 | +```text |
| 169 | +> status |
| 170 | +
|
| 171 | +Status: |
| 172 | + Task logging: ENABLED |
| 173 | + LogLevel: 1 (0=DEBUG,1=INFO,2=WARN,3=ERROR) |
| 174 | + PowerMode: 2 (0=ACTIVE,1=IDLE,2=SLEEP,3=STOP) |
| 175 | + Sensor sample period: 30000 ms |
| 176 | +``` |
| 177 | + |
| 178 | +Where: |
| 179 | + |
| 180 | +- **Task logging** → whether task logs are enabled |
| 181 | +- **LogLevel** → current minimum log level |
| 182 | +- **PowerMode** → current abstract mode |
| 183 | +- **Sensor sample period** → effective period based on power mode |
| 184 | + (0 in STOP mode, meaning sampling is disabled) |
| 185 | + |
| 186 | +--- |
| 187 | + |
| 188 | +## Example Session |
| 189 | + |
| 190 | +```text |
| 191 | +Smart Sensor Hub CLI ready. |
| 192 | +Type 'help' for a list of commands. |
| 193 | +
|
| 194 | +> help |
| 195 | +Available commands: |
| 196 | + help - Show this help text |
| 197 | + log off - Disable all task logging |
| 198 | + log error - Task logs at ERROR level only |
| 199 | + log warn - Task logs at WARN and above |
| 200 | + log info - Task logs at INFO and above |
| 201 | + log debug - Task logs at DEBUG and above |
| 202 | + log pause - Temporarily pause all task logs |
| 203 | + log resume - Resume task logs to previous state |
| 204 | + pmode active - Request POWER_MODE_ACTIVE |
| 205 | + pmode idle - Request POWER_MODE_IDLE |
| 206 | + pmode sleep - Request POWER_MODE_SLEEP |
| 207 | + pmode stop - Request POWER_MODE_STOP |
| 208 | + status - Show logging and power status |
| 209 | +
|
| 210 | +> log debug |
| 211 | +Task logging enabled, level=DEBUG. |
| 212 | +
|
| 213 | +[00001234 ms][DBG][../app/app_task_manager.c:77][AppTaskManager_RunOnce] Running task 'Heartbeat' (elapsed: 500 ms) |
| 214 | +
|
| 215 | +> pmode sleep |
| 216 | +Requested power mode change: sleep |
| 217 | +
|
| 218 | +> status |
| 219 | +Status: |
| 220 | + Task logging: ENABLED |
| 221 | + LogLevel: 0 (0=DEBUG,1=INFO,2=WARN,3=ERROR) |
| 222 | + PowerMode: 2 (0=ACTIVE,1=IDLE,2=SLEEP,3=STOP) |
| 223 | + Sensor sample period: 30000 ms |
| 224 | +
|
| 225 | +> pmode stop |
| 226 | +Requested power mode change: stop |
| 227 | +
|
| 228 | +> status |
| 229 | +Status: |
| 230 | + Task logging: ENABLED |
| 231 | + LogLevel: 0 (0=DEBUG,1=INFO,2=WARN,3=ERROR) |
| 232 | + PowerMode: 3 (0=ACTIVE,1=IDLE,2=SLEEP,3=STOP) |
| 233 | + Sensor sample period: 0 ms (sampling disabled in STOP) |
| 234 | +``` |
| 235 | + |
| 236 | +This file serves as a quick reference for anyone interacting with the firmware via UART. |
0 commit comments