Browse Source

Rearrange commands in shell.c to match docs

Now the commands are in the same order in shell.c, the printed list, and
console_config.md.
Clara Hobbs 6 years ago
parent
commit
32743bb95e
1 changed files with 51 additions and 51 deletions
  1. 51
    51
      src/shell.c

+ 51
- 51
src/shell.c View File

@@ -158,28 +158,47 @@ static void cmd_license(BaseSequentialStream *chp, int argc, char *argv[])
158 158
     );
159 159
 }
160 160
 
161
-static void cmd_erase(BaseSequentialStream *chp, int argc, char *argv[])
161
+static void cmd_identify(BaseSequentialStream *chp, int argc, char *argv[])
162 162
 {
163
+    (void) chp;
163 164
     (void) argv;
164 165
     if (argc > 0) {
165
-        chprintf(chp, "Usage: erase\r\n");
166
+        chprintf(chp, "Usage: identify\r\n");
166 167
         return;
167 168
     }
168 169
 
169
-    pdbs_config_flash_erase();
170
+    chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_IDENTIFY);
170 171
 }
171 172
 
172
-static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[])
173
+static void cmd_get_cfg(BaseSequentialStream *chp, int argc, char *argv[])
173 174
 {
174
-    (void) argv;
175
-    if (argc > 0) {
176
-        chprintf(chp, "Usage: write\r\n");
175
+    struct pdbs_config *cfg = NULL;
176
+
177
+    if (argc > 1) {
178
+        chprintf(chp, "Usage: get_cfg [index]\r\n");
177 179
         return;
178 180
     }
179 181
 
180
-    pdbs_config_flash_update(&tmpcfg);
181
-
182
-    chEvtSignal(pdb_config->pe.thread, PDB_EVT_PE_NEW_POWER);
182
+    /* With no arguments, find the current configuration */
183
+    if (argc == 0) {
184
+        cfg = pdbs_config_flash_read();
185
+        if (cfg == NULL) {
186
+            chprintf(chp, "No configuration\r\n");
187
+            return;
188
+        }
189
+    /* With an argument, get a particular configuration array index */
190
+    } else if (argc == 1) {
191
+        char *endptr;
192
+        long i = strtol(argv[0], &endptr, 0);
193
+        if (i >= 0 && i < PDBS_CONFIG_ARRAY_LEN && endptr > argv[0]) {
194
+            cfg = &pdbs_config_array[i];
195
+        } else {
196
+            chprintf(chp, "Invalid index\r\n");
197
+            return;
198
+        }
199
+    }
200
+    /* Print the configuration */
201
+    pdbs_config_print(chp, cfg);
183 202
 }
184 203
 
185 204
 static void cmd_load(BaseSequentialStream *chp, int argc, char *argv[])
@@ -206,35 +225,28 @@ static void cmd_load(BaseSequentialStream *chp, int argc, char *argv[])
206 225
     tmpcfg.vmax = cfg->vmax;
207 226
 }
208 227
 
209
-static void cmd_get_cfg(BaseSequentialStream *chp, int argc, char *argv[])
228
+static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[])
210 229
 {
211
-    struct pdbs_config *cfg = NULL;
212
-
213
-    if (argc > 1) {
214
-        chprintf(chp, "Usage: get_cfg [index]\r\n");
230
+    (void) argv;
231
+    if (argc > 0) {
232
+        chprintf(chp, "Usage: write\r\n");
215 233
         return;
216 234
     }
217 235
 
218
-    /* With no arguments, find the current configuration */
219
-    if (argc == 0) {
220
-        cfg = pdbs_config_flash_read();
221
-        if (cfg == NULL) {
222
-            chprintf(chp, "No configuration\r\n");
223
-            return;
224
-        }
225
-    /* With an argument, get a particular configuration array index */
226
-    } else if (argc == 1) {
227
-        char *endptr;
228
-        long i = strtol(argv[0], &endptr, 0);
229
-        if (i >= 0 && i < PDBS_CONFIG_ARRAY_LEN && endptr > argv[0]) {
230
-            cfg = &pdbs_config_array[i];
231
-        } else {
232
-            chprintf(chp, "Invalid index\r\n");
233
-            return;
234
-        }
236
+    pdbs_config_flash_update(&tmpcfg);
237
+
238
+    chEvtSignal(pdb_config->pe.thread, PDB_EVT_PE_NEW_POWER);
239
+}
240
+
241
+static void cmd_erase(BaseSequentialStream *chp, int argc, char *argv[])
242
+{
243
+    (void) argv;
244
+    if (argc > 0) {
245
+        chprintf(chp, "Usage: erase\r\n");
246
+        return;
235 247
     }
236
-    /* Print the configuration */
237
-    pdbs_config_print(chp, cfg);
248
+
249
+    pdbs_config_flash_erase();
238 250
 }
239 251
 
240 252
 static void cmd_get_tmpcfg(BaseSequentialStream *chp, int argc, char *argv[])
@@ -325,18 +337,6 @@ static void cmd_set_i(BaseSequentialStream *chp, int argc, char *argv[])
325 337
     }
326 338
 }
327 339
 
328
-static void cmd_identify(BaseSequentialStream *chp, int argc, char *argv[])
329
-{
330
-    (void) chp;
331
-    (void) argv;
332
-    if (argc > 0) {
333
-        chprintf(chp, "Usage: identify\r\n");
334
-        return;
335
-    }
336
-
337
-    chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_IDENTIFY);
338
-}
339
-
340 340
 static void cmd_output(BaseSequentialStream *chp, int argc, char *argv[])
341 341
 {
342 342
     if (argc == 0) {
@@ -405,19 +405,19 @@ static void cmd_get_source_cap(BaseSequentialStream *chp, int argc, char *argv[]
405 405
  */
406 406
 static const struct pdbs_shell_cmd commands[] = {
407 407
     {"license", cmd_license, "Show copyright and license information"},
408
-    {"erase", cmd_erase, "Erase all stored configuration"},
409
-    {"write", cmd_write, "Store the configuration buffer"},
410
-    {"load", cmd_load, "Load the stored configuration into the buffer"},
408
+    {"identify", cmd_identify, "Blink the LED to identify the device"},
411 409
     {"get_cfg", cmd_get_cfg, "Print the stored configuration"},
410
+    {"load", cmd_load, "Load the stored configuration into the buffer"},
411
+    {"write", cmd_write, "Store the configuration buffer"},
412
+    {"erase", cmd_erase, "Erase all stored configuration"},
412 413
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
413 414
     {"clear_flags", cmd_clear_flags, "Clear all flags"},
414 415
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
415 416
     {"toggle_hv_preferred", cmd_toggle_hv_preferred, "Toggle the HV_Preferred flag"},
416 417
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
417 418
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},
419
+    /* TODO {"set_vrange", cmd_set_vrange, "Set the minimum and maximum voltage in millivolts"},*/
418 420
     {"set_i", cmd_set_i, "Set the current in milliamps"},
419
-    /* TODO {"set_v_range", cmd_set_v_range, "Set the minimum and maximum voltage in millivolts"},*/
420
-    {"identify", cmd_identify, "Blink the LED to identify the device"},
421 421
     {"output", cmd_output, "Get or set the output status"},
422 422
     {"get_source_cap", cmd_get_source_cap, "Print the capabilities of the PD source"},
423 423
     {NULL, NULL, NULL}

Loading…
Cancel
Save