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: mbed SerialInputReactionHandler StrCommandHandler
Revision 0:4749705f54ab, committed 2019-10-31
- Comitter:
- aktk
- Date:
- Thu Oct 31 18:59:53 2019 +0000
- Child:
- 1:c39728f6555e
- Commit message:
- Confirmed.;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/StrCommandHandler.lib Thu Oct 31 18:59:53 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/aktk/code/StrCommandHandler/#1d46d90eb7bf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 31 18:59:53 2019 +0000
@@ -0,0 +1,78 @@
+#include "mbed.h"
+#include "StrCommandHandler.h"
+
+DigitalOut myled1(LED1);
+
+DigitalOut myled2(LED2);
+
+DigitalOut myled3(LED3);
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+StrCommandHandler cmdHandler(5);
+
+int func1(void)
+{
+ myled1 = 1;
+ myled2 = 0;
+ myled3 = 0;
+ return 1;
+}
+
+int func2(void)
+{
+ myled1 = 0;
+ myled2 = 1;
+ myled3 = 0;
+ return 2;
+}
+
+int func3(void)
+{
+ myled1 = 0;
+ myled2 = 0;
+ myled3 = 1;
+ return 3;
+}
+
+int main()
+{
+ char command[16] ;
+ int itr = 0;
+ int rlt;
+
+ pc.baud(921600);
+
+ cmdHandler.map("func1", func1);
+ cmdHandler.map("func2", func2);
+ cmdHandler.map("func3", func3);
+
+ cmdHandler.list();
+
+PRELOOP:
+ pc.puts("\ncommand: ");
+ itr = 0;
+
+ while(1) {
+ command[itr] = pc.getc();
+ if(
+ command[itr] == '\r'
+ || command[itr] == '\n'
+ ) {
+ command[itr] = '\0';
+ pc.puts("\n");
+ pc.puts("reveived: ");
+ pc.puts(command);
+ pc.puts("\t");
+ rlt = cmdHandler.exe(command);
+ printf("result: %x\n", rlt);
+ break;
+ } else {
+ pc.putc(command[itr]);
+ }
+ if (itr == 15)
+ break;
+ itr++;
+ }
+ goto PRELOOP;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 31 18:59:53 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file