Myserial Library extends RawSerial

Files at this revision

API Documentation at this revision

Comitter:
naao
Date:
Fri Jul 04 11:06:02 2014 +0000
Parent:
14:8bd054a87ac5
Child:
16:596e062f6c45
Commit message:
correct cWord initiate size

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 05:41:39 2014 +0000
+++ b/MySerial.cpp	Fri Jul 04 11:06:02 2014 +0000
@@ -16,7 +16,7 @@
 {
     int i=0;
     int ichar;
-    memset(cWord, '\0', strlen(cWord));  //initialise chars
+    memset(cWord, '\0', size+1);  //initialise chars
 
     wait(fRxStartWait);
 
--- a/MySerial.h	Thu Jul 03 05:41:39 2014 +0000
+++ b/MySerial.h	Fri Jul 04 11:06:02 2014 +0000
@@ -23,9 +23,11 @@
  * 
  * 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(6,&cWord);    //Serial received chars by pointer cWord
  *    int iRtn =  pc.GetString(6,cWord); //Serial received chars byref of cWord
  * }