Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed
cli.cpp@2:e699312248f3, 2016-12-05 (annotated)
- Committer:
- micbio
- Date:
- Mon Dec 05 22:46:14 2016 +0000
- Revision:
- 2:e699312248f3
- Parent:
- 1:58d2021e301d
ad
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
micbio | 1:58d2021e301d | 1 | #include "cli.hpp" |
micbio | 1:58d2021e301d | 2 | |
micbio | 1:58d2021e301d | 3 | #define CMD_LENGTH 15 |
micbio | 1:58d2021e301d | 4 | |
micbio | 1:58d2021e301d | 5 | extern Serial pc; |
micbio | 1:58d2021e301d | 6 | |
micbio | 1:58d2021e301d | 7 | void cli_sd::welcome(void) |
micbio | 1:58d2021e301d | 8 | { |
micbio | 2:e699312248f3 | 9 | printf("***********************************************\r\n"); |
micbio | 2:e699312248f3 | 10 | printf("** Welcome to an example application showing **\r\n"); |
micbio | 2:e699312248f3 | 11 | printf("** basic file operations on sd card. **\r\n"); |
micbio | 2:e699312248f3 | 12 | printf("***********************************************\r\n"); |
micbio | 1:58d2021e301d | 13 | } |
micbio | 1:58d2021e301d | 14 | |
micbio | 1:58d2021e301d | 15 | void cli_sd::print_help(void) |
micbio | 1:58d2021e301d | 16 | { |
micbio | 2:e699312248f3 | 17 | pc.printf("List of commands:\r\n"); |
micbio | 2:e699312248f3 | 18 | pc.printf("m : mounts a sd_card\r\n"); |
micbio | 2:e699312248f3 | 19 | pc.printf("p : changes the file to write to\r\n"); |
micbio | 2:e699312248f3 | 20 | pc.printf("w : write to example file\r\n"); |
micbio | 2:e699312248f3 | 21 | pc.printf("a : append to example file\r\n"); |
micbio | 2:e699312248f3 | 22 | pc.printf("r : read text from example file\r\n"); |
micbio | 1:58d2021e301d | 23 | } |
micbio | 1:58d2021e301d | 24 | |
micbio | 1:58d2021e301d | 25 | char cli_sd::get_cmd(void) |
micbio | 1:58d2021e301d | 26 | { |
micbio | 1:58d2021e301d | 27 | char c; |
micbio | 1:58d2021e301d | 28 | while(true) |
micbio | 1:58d2021e301d | 29 | { |
micbio | 1:58d2021e301d | 30 | c = pc.getc(); |
micbio | 1:58d2021e301d | 31 | if (c == 'm' || c == 'p' || c == 'w' || c == 'a' || c == 'r') |
micbio | 1:58d2021e301d | 32 | { |
micbio | 1:58d2021e301d | 33 | break; |
micbio | 1:58d2021e301d | 34 | } |
micbio | 1:58d2021e301d | 35 | else |
micbio | 1:58d2021e301d | 36 | { |
micbio | 2:e699312248f3 | 37 | pc.printf("Unkown command.\r\n"); |
micbio | 1:58d2021e301d | 38 | this->print_help(); |
micbio | 1:58d2021e301d | 39 | } |
micbio | 1:58d2021e301d | 40 | } |
micbio | 1:58d2021e301d | 41 | |
micbio | 1:58d2021e301d | 42 | return c; |
micbio | 1:58d2021e301d | 43 | } |