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.
SerialBuffered.h
00001 #ifndef _SERIAL_BUFFERED_H_ 00002 #define _SERIAL_BUFFERED_H_ 00003 00004 #include "mbed.h" 00005 00006 /** 00007 * Buffered serial class. 00008 */ 00009 class SerialBuffered : public Serial 00010 { 00011 public: 00012 /** 00013 * Create a buffered serial class. 00014 * 00015 * @param tx A pin for transmit. 00016 * @param rx A pin for receive. 00017 */ 00018 SerialBuffered(PinName tx, PinName rx); 00019 00020 /** 00021 * Destroy. 00022 */ 00023 virtual ~SerialBuffered(); 00024 00025 /** 00026 * Get a character. 00027 * 00028 * @return A character. (-1:timeout) 00029 */ 00030 int getc(); 00031 00032 /** 00033 * Returns 1 if there is a character available to read, otherwise. 00034 */ 00035 int readable(); 00036 00037 /** 00038 * Set timeout for getc(). 00039 * 00040 * @param ms milliseconds. (-1:Disable timeout) 00041 */ 00042 void setTimeout(int ms); 00043 00044 /** 00045 * Read requested bytes. 00046 * 00047 * @param bytes A pointer to a buffer. 00048 * @param requested Length. 00049 * 00050 * @return Readed byte length. 00051 */ 00052 size_t readBytes(uint8_t *bytes, size_t requested); 00053 00054 float f_readIntTo(char delimiter); 00055 int i_readIntTo(char delimiter); 00056 void writeText(char* text); 00057 00058 private: 00059 void handleInterrupt(); 00060 00061 static const int BUFFERSIZE = 2048; 00062 static const int BUFFER_TEXT_SIZE = 255; 00063 00064 uint8_t buffer[BUFFERSIZE]; // points at a circular buffer, containing data from m_contentStart, for m_contentSize bytes, wrapping when you get to the end 00065 uint16_t indexContentStart; // index of first bytes of content 00066 uint16_t indexContentEnd; // index of bytes after last byte of content 00067 int timeout; 00068 Timer timer; 00069 }; 00070 00071 #endif
Generated on Tue Jul 19 2022 01:26:58 by
1.7.2