TUB-MRT / btbee

Fork of btbee by Nikolas Goldin

Files at this revision

API Documentation at this revision

Comitter:
ngoldin
Date:
Thu May 16 12:09:30 2013 +0000
Parent:
0:e7cb710c8900
Child:
2:12c38a710982
Commit message:
fixed;

Changed in this revision

btbee.cpp Show annotated file Show diff for this revision Revisions of this file
btbee.h Show annotated file Show diff for this revision Revisions of this file
--- a/btbee.cpp	Thu May 16 10:24:06 2013 +0000
+++ b/btbee.cpp	Thu May 16 12:09:30 2013 +0000
@@ -18,3 +18,21 @@
 reset_out.write(1);
 }
 
+
+/* Read from the serial as long as it is readable. 
+*  Params: pointer to char array for the return, 
+*          int containing the length of the char array
+*          pointer to int for return of chars read 
+*  Return: 1 if ok, 0 if array full but more there to read
+*/
+int btbee::read_all(char * arr, const int len, int * chars_read){
+int pos=0;
+while (readable()){
+    if (pos==len){return 0;}
+    arr[pos]=getc(); 
+    pos++;
+    *chars_read = pos;
+}
+return 1;
+}
+
--- a/btbee.h	Thu May 16 10:24:06 2013 +0000
+++ b/btbee.h	Thu May 16 12:09:30 2013 +0000
@@ -6,6 +6,7 @@
   btbee(PinName respin, PinName tx, PinName rx);
   btbee(void);
   void reset(void);
+  int read_all(char*,const int, int*);
 
  protected:
   DigitalOut reset_out;