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 Class Reference
MySerial control class, based on a RawSerial. More...
#include <MySerial.h>
Public Member Functions | |
| MySerial (PinName tx, PinName rx) | |
| constructor to get chars received by serial | |
| void | SetRxWait (float _fRxStartWait, float _fRxEachWait) |
| set wait getting chars after interrupted | |
| virtual int | GetString (int size, char *cWord) |
| function to get chars after received chars by serial | |
| template<class X > | |
| int | GetString (int size, X cWord) |
| overload function to get chars after received chars by serial | |
Detailed Description
MySerial control class, based on a RawSerial.
Example:
#include "mbed.h" #include "MySerial.h" MySerial pc(USBTX,USBRX); //instance of MySerial Class char cWord[16]; //receive chars or cWord[256], cWord[1024] etc.. int readSize = 15; void readbuf() { if (readSize >= sizeof(cWord)) { readSize = sizeof(cWord)-1; } // int iRtn = pc.GetString(readSize,&cWord); //Serial received chars by pointer cWord int iRtn = pc.GetString(readSize,cWord); //Serial received chars byref of cWord } int main() { pc.baud(9600); //set baud rate pc.format(8, MySerial::None, 1);//set bits for a byte, parity bit, stop bit pc.SetRxWait(0.01, 0.001); //set wait getting chars after interrupted, each char pc.attach( readbuf, MySerial::RxIrq ); //Set Interrupt by Serial receive }
Definition at line 42 of file MySerial.h.
Constructor & Destructor Documentation
| MySerial | ( | PinName | tx, |
| PinName | rx | ||
| ) |
constructor to get chars received by serial
- Parameters:
-
PinName tx PinName rx
Definition at line 3 of file MySerial.cpp.
Member Function Documentation
| int GetString | ( | int | size, |
| char * | cWord | ||
| ) | [virtual] |
function to get chars after received chars by serial
- Parameters:
-
int size for get chars *cWord returns got chars by pointer returns success by 0
Definition at line 15 of file MySerial.cpp.
| int GetString | ( | int | size, |
| X | cWord | ||
| ) |
overload function to get chars after received chars by serial
- Parameters:
-
int size for get chars cWord returns got chars by ref returns success by 0
Definition at line 74 of file MySerial.h.
| void SetRxWait | ( | float | _fRxStartWait, |
| float | _fRxEachWait | ||
| ) |
set wait getting chars after interrupted
- Parameters:
-
float _fRxStartWait wait getting a 1st char after interrupted float _fRxEachWait wait getting each char
Definition at line 9 of file MySerial.cpp.
Generated on Thu Jul 14 2022 03:52:59 by
1.7.2