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.
Reader.cpp
00001 #include "Reader.h" 00002 #include "Pinout.h" 00003 #include "Log.h" 00004 00005 00006 extern Log _; 00007 00008 Reader::Reader() 00009 { 00010 this->clock = Clock::getInstance(); 00011 } 00012 00013 Reader* Reader::getInstance() 00014 { 00015 static Reader* instance = new Reader(); 00016 return instance; 00017 } 00018 00019 const string Reader::readLine(uint32_t timeout, bool showPrompt) 00020 { 00021 if (showPrompt) { 00022 _.ln().print("Prueba Hsens $ "); 00023 } 00024 _.flush(); 00025 00026 string line = ""; 00027 time_t currentTime = this->clock->getUnixTime(); 00028 bool completedLine = false; 00029 00030 Serial* console = _.getSerial(); 00031 while ((uint32_t)(this->clock->getUnixTime() - currentTime) <= timeout && !completedLine) { 00032 if (console->readable()) { 00033 char ch = console->getc(); 00034 _.print(ch); 00035 switch (ch) { 00036 case '\r': 00037 case '\n': 00038 completedLine = true; 00039 break; 00040 default: 00041 line += ch; 00042 } 00043 } 00044 } 00045 if (completedLine) { 00046 _.ln(); 00047 return line; 00048 } else { 00049 return ""; 00050 } 00051 }
Generated on Fri Aug 19 2022 07:33:34 by
1.7.2