This is a very simple guide, reviewing the steps required to get Blinky working on an Mbed OS platform.

Dependencies:   RemoteIR

Revision:
120:a1dd83d9c036
Parent:
119:d879334e3d87
Child:
121:450f119863a7
--- a/main.cpp	Fri Apr 17 15:46:27 2020 +0000
+++ b/main.cpp	Fri Apr 17 16:32:02 2020 +0000
@@ -1,9 +1,13 @@
 #include "mbed.h"
 #include <string.h>
 
-RawSerial pc(PA_2, PA_3, 115200); // USART2
-//Serial pc(USBTX, USBRX);
-//RawSerial phone(PA_10, PA_9, 115200);
+//RawSerial pc(USBTX, USBRX);
+//RawSerial pc(D2, D8,115200);
+//RawSerial pc(PA10, PA9, 115200); // USART2
+
+//RawSerial pc(D8, D2,115200);
+RawSerial pc(PA_9, PA_10, 9600); // USART2
+
 DigitalOut rLed(D3);
 DigitalOut gLed(D4);
 
@@ -12,14 +16,16 @@
 
 void rx_handler(void) {
     int ch = pc.getc();
-    pc.putc(ch);
 //    phone.putc(ch);
     
     if(ch == 0x0D) {
                 while(!pc.writeable());
+                
                 pc.putc(0x0A);
 //                phone.putc(0x0A);
                 
+//                pc.printf("buf: %s\r\n",buf);
+                
                 if(strcmp(buf,"Rled on") == 0) {
                     rLed = 1;
                     pc.printf("Rled status: %s\r\n", "on");
@@ -52,10 +58,13 @@
                     pc.printf("Undefined command\r\n");
 //                    phone.printf("Undefined command\r\n");
                 }
-                strncpy(buf,"",index);
+                for(int i = 0; i < index; i++) buf[i] = '\0';
+//                pc.printf("cleaned buf: '%s'\r\n", buf);
                 index = 0;
-    } else {
+    } else if(ch != 10){
     
+        pc.putc(ch);
+//        pc.printf("%d",ch);
         buf[index] = ch;
         index ++;
     }