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.
MySerial.cpp
00001 #include "MySerial.h" 00002 00003 MySerial::MySerial(PinName tx,PinName rx):Serial(tx,rx) //constructor 00004 { 00005 fRxStartWait = 0.01; //wait getting a 1st char after interrupted 00006 fRxEachWait = 0.001; //wait getting each char 00007 } 00008 00009 void MySerial::SetRxWait(float _fRxStartWait, float _fRxEachWait) 00010 { 00011 fRxStartWait = _fRxStartWait; //wait getting a 1st char after interrupted 00012 fRxEachWait = _fRxEachWait; //wait getting each char 00013 } 00014 00015 int MySerial::GetString(int size, char *cWord) //by pointer 00016 { 00017 int i=0; 00018 int ichar; 00019 memset(cWord, '\0', size+1); //initialise chars 00020 00021 wait(fRxStartWait); 00022 00023 while(1) { 00024 if(!readable()) { 00025 break; 00026 } 00027 ichar = getc(); 00028 if(i<size) { 00029 cWord[i] =ichar; 00030 //putc(ichar); 00031 } 00032 i++; 00033 wait(fRxEachWait); 00034 } 00035 return 0; 00036 }
Generated on Thu Jul 14 2022 03:52:59 by
1.7.2