Myserial Library extends RawSerial

Files at this revision

API Documentation at this revision

Comitter:
naao
Date:
Thu Jul 03 03:19:26 2014 +0000
Parent:
11:34ae126807a0
Child:
13:8cf9a9d7d44d
Commit message:
changed base library to SerialBase and reffers to RawSerial

Changed in this revision

MySerial.cpp Show annotated file Show diff for this revision Revisions of this file
MySerial.h Show annotated file Show diff for this revision Revisions of this file
--- a/MySerial.cpp	Thu Jul 03 02:37:41 2014 +0000
+++ b/MySerial.cpp	Thu Jul 03 03:19:26 2014 +0000
@@ -1,11 +1,25 @@
 #include "MySerial.h"
 
-MySerial::MySerial(PinName tx,PinName rx, char *name):Serial(tx,rx,name)          //constructor
+MySerial::MySerial(PinName tx,PinName rx):SerialBase(tx,rx)          //constructor
 {
     fRxStartWait = 0.01;    //wait getting a 1st char after interrupted
     fRxEachWait = 0.001;    //wait getting each char
 }
 
+int MySerial::getc() {
+    return _base_getc();
+}
+ 
+int MySerial::putc(int c) {
+    return _base_putc(c);
+}
+ 
+int MySerial::puts(const char *str) {
+    while (*str)
+        putc(*str ++);
+    return 0;
+}
+
 void MySerial::SetRxWait(float _fRxStartWait, float _fRxEachWait)
 {
     fRxStartWait = _fRxStartWait;   //wait getting a 1st char after interrupted
--- a/MySerial.h	Thu Jul 03 02:37:41 2014 +0000
+++ b/MySerial.h	Thu Jul 03 03:19:26 2014 +0000
@@ -38,17 +38,40 @@
  * }
  * @endcode
  */
-class MySerial : public Serial{
+class MySerial : public SerialBase{
     
 public:
-    /** constructor to get chars received by serial
+   
+     /** constructor to get chars received by serial
      * 
      * @param PinName tx
      * @param PinName rx
      */
-    MySerial(PinName tx, PinName rx, char *name);
-   
-    /** set wait getting chars after interrupted
+    MySerial(PinName tx, PinName rx);
+
+    /** Write a char to the serial port
+     *
+     * @param c The char to write
+     *
+     * @returns The written char or -1 if an error occured
+     */
+    int putc(int c);
+ 
+    /** Read a char from the serial port
+     *
+     * @returns The char read from the serial port
+     */
+    int getc();
+ 
+    /** Write a string to the serial port
+     *
+     * @param str The string to write
+     *
+     * @returns 0 if the write succeeds, EOF for error
+     */
+    int puts(const char *str);
+
+   /** set wait getting chars after interrupted
      * 
      * @param float _fRxStartWait wait getting a 1st char after interrupted
      * @param float _fRxEachWait wait getting each char