Interactive serial interface for sending commands to an embedded system using serial communications. This will be helpful if you want to send commands to serial port and be able to correct the wrong text entered at the terminal
Revision 5:bfc6c756c8e9, committed 2019-09-02
- Comitter:
- mjm2016
- Date:
- Mon Sep 02 12:28:53 2019 +0000
- Parent:
- 4:183056edc0f4
- Commit message:
- Bug fixed
Changed in this revision
diff -r 183056edc0f4 -r bfc6c756c8e9 main.cpp --- a/main.cpp Wed Sep 20 06:18:04 2017 +0000 +++ b/main.cpp Mon Sep 02 12:28:53 2019 +0000 @@ -1,10 +1,11 @@ #include "mbed.h" /* - COPYWRITE Mariwan Jalal - This function will take a string from the terminal and save it in a buffer. + Author Mariwan Jalal + This function will take a string from the terminal and save it in a buffer. The string is editable during the time user input the string. This will be useful if any one want to have an interactive interface for an application. USE IT AT YOUR OWN RESPONSIBILITY .. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND + Free to use. */ @@ -20,27 +21,30 @@ stringBuf[i]=pc.getc(); if(stringBuf[i]=='\n') { stringBuf[i]='\0'; - if (i>0){ - i--; - if(stringBuf[i]=='\r') { - stringBuf[i]='\0'; + if (i>0) { + i--; + if(stringBuf[i]=='\r') { + stringBuf[i]='\0'; + } + return; } - return; } if(stringBuf[i]=='\b') { pc.puts("\b \b"); stringBuf[i]='\0'; - if (i>0){ - i--; + if (i>0) { + i--; } - stringBuf[i]='\0'; + stringBuf[i]='\0'; + } else { pc.putc(stringBuf[i]); i++; } - + } } + int main() { pc.baud(BAUD_RATE_); // DEFAULT IS 9600, THIS IS JUST FOR NOTIFICATION FOR THE READER.
diff -r 183056edc0f4 -r bfc6c756c8e9 mbed-os.lib --- a/mbed-os.lib Wed Sep 20 06:18:04 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://github.com/ARMmbed/mbed-os/#ca661f9d28526ca8f874b05432493a489c9671ea
diff -r 183056edc0f4 -r bfc6c756c8e9 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Sep 02 12:28:53 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/994bdf8177cb \ No newline at end of file