Eng Riyadh / mbed_function
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial.cpp Source File

serial.cpp

00001 #include "serial.h"
00002 
00003 char* buffer = new char[BUFFER_SIZE];
00004 
00005 USB_Serial serial;
00006 
00007 void USB_Serial::flush() {
00008     while(serial.readable())
00009         serial.getc();
00010 }
00011 
00012 int USB_Serial::gets (char* str, int size) {
00013     int i=0;
00014     char c;
00015     while(1) {
00016         c = serial.getc();
00017         if(c=='\r' || c=='\n') break;
00018         str[i++] = c;
00019         if(i+1==size) break;
00020     }
00021     str[i]=0;
00022     return i;
00023 }
00024