Inherit from Serial and use software buffers for TX and RX. This allows the UART peripherals to operate in a IRQ driven mode. Overrides most (but not all) stdio functions as Serial did

Dependencies:   Buffer

Dependents:   mbed_esp8266_demo

Fork of BufferedSerial by Sam Grove

Revision:
2:7e8a450a9101
Parent:
1:57a11fb5d529
Child:
3:6b76fcf27545
--- a/BufferedSerial.h	Thu May 23 23:47:04 2013 +0000
+++ b/BufferedSerial.h	Fri May 24 22:00:26 2013 +0000
@@ -73,8 +73,8 @@
 class BufferedSerial : public Serial 
 {
 private:
-    Buffer <char> _rxbuf;
-    Buffer <char> _txbuf;
+    Buffer <char>   _rxbuf;
+    Buffer <char>   _txbuf;
  
     void rxIrq(void);
     void txIrq(void);
@@ -110,22 +110,28 @@
     
     /** Write a single byte to the BufferedSerial Port.
      *  @param c The byte to write to the Serial Port
-     *  @return The byte that was written to the Serial Port
+     *  @return The byte that was written to the Serial Port Buffer
      */
     virtual int putc(int c);
     
     /** Write a string to the BufferedSerial Port. Must be NULL terminated
      *  @param s The string to write to the Serial Port
-     *  @return The number of bytes written to the Serial Port
+     *  @return The number of bytes written to the Serial Port Buffer
      */
     virtual int puts(const char *s);
     
     /** Write a formatted string to the BufferedSerial Port.
      *  @param format The string + format specifiers to write to the Serial Port
-     *  @return The number of bytes written to the Serial Port
+     *  @return The number of bytes written to the Serial Port Buffer
      */
     virtual int printf(const char* format, ...);
     
+    /** Write data to the Buffered Serial Port
+     *  @param s A pointer to data to send
+     *  @param length The amount of data being pointed to
+     *  @return The number of bytes written to the Serial Port Buffer
+     */
+    virtual ssize_t write(const void *s, std::size_t length);
 };
 
 #endif