STDin and STDout example

Dependencies:   mbed

Committer:
lmottola
Date:
Tue Mar 19 13:54:37 2019 +0000
Revision:
2:677b83cb846c
Parent:
1:2f9d56e97f30
Added alternate version to process serial data from a host program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lmottola 0:8c4e69ec8e4d 1 #include "mbed.h"
lmottola 0:8c4e69ec8e4d 2
lmottola 0:8c4e69ec8e4d 3 Serial pc(USBTX, USBRX);
lmottola 0:8c4e69ec8e4d 4
lmottola 0:8c4e69ec8e4d 5 int main() {
lmottola 2:677b83cb846c 6
lmottola 0:8c4e69ec8e4d 7 char buffer[128];
lmottola 0:8c4e69ec8e4d 8 pc.printf("Starting..\n");
lmottola 2:677b83cb846c 9 // int count = 0;
lmottola 0:8c4e69ec8e4d 10
lmottola 0:8c4e69ec8e4d 11 while (1) {
lmottola 0:8c4e69ec8e4d 12 pc.gets(buffer, 4);
lmottola 0:8c4e69ec8e4d 13 pc.printf("I got '%s'\n", buffer);
lmottola 2:677b83cb846c 14
lmottola 2:677b83cb846c 15 // Alternate version to process data over serial from a host program...
lmottola 2:677b83cb846c 16 // pc.printf("The counter is '%d'\n", count);
lmottola 2:677b83cb846c 17 // count++;
lmottola 2:677b83cb846c 18 // wait (1);
lmottola 0:8c4e69ec8e4d 19 }
lmottola 0:8c4e69ec8e4d 20 }