Echos ASCII message converted to uppercase. Uses toupper function from standard C library.

Dependencies:   mbed

Revision:
1:ea72a608382f
Parent:
0:2f9e67d4c561
Child:
2:e53dfe50252a
--- a/main.cpp	Tue May 16 20:32:12 2017 +0000
+++ b/main.cpp	Thu Nov 09 15:21:35 2017 +0000
@@ -1,25 +1,41 @@
+/* 
+    Project: SerialRelay
+    File: main.cpp
+    Created by: Dr. C. S. Tritt
+    Last revised: 11/8/17
+    
+    Relays serial data from PC to Nucleo Serial3 (PC_10 for TX, PC_11 for RX).
+    
+    Tera Term configurations
+    Terminal - New-line, Receive LF, Transmit LF
+    Serial port - Data 8 bit, Parity none, Stop 1 bit, Flow control none.
+    Baud as specified below.
+*/
 #include "mbed.h"
 
 //------------------------------------
-// Tera Term configurations
-// Terminal - New-line, Receive LF, Transmit LF
-// Serial port - Data 8 bit, Parity none, Stop 1 bit data, Flow control none.
-// Baud as specified below.
+
 //------------------------------------
 
-// Serial pc(SERIAL_TX, SERIAL_RX, 921600); // Highest Tera Term speed - works.
-Serial pc(USBTX, USBRX, 115200); // Highest common speed - works.
-// Serial pc(USBTX, USBRX); // Default 9600 baud, alternate pin names - works.
+Serial pc(USBTX, USBRX, 9600); // Standard to PC via USB channel.
+Serial bc(PC_10, PC_11, 9600); // Serial3. Pins at top of left Morphio header.
 
-DigitalOut myled(LED1);
+DigitalOut actLED(LED1); // Activity toggle.
 
 int main()
 {
-    int i = 1;
-    pc.printf("Hello World !\n");
-    while(1) {
-        wait(1);
-        pc.printf("This program runs since %d seconds.\n", i++);
-        myled = !myled;
+    while (true) {
+        if (pc.readable()) {
+            char character = (char) pc.getc();
+            //pc.putc(character);
+            bc.putc(character);
+            actLED = !actLED;
+        }
+        if (bc.readable()) {
+            char character = (char) bc.getc();
+            //bc.putc(character);
+            pc.putc(character);
+            actLED = !actLED;
+        }
     }
 }
\ No newline at end of file