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.
Dependencies: SensoryTest
Fork of btbee by
Revision 3:ddeb620fb25e, committed 2014-02-05
- Comitter:
- ngoldin
- Date:
- Wed Feb 05 10:32:04 2014 +0000
- Parent:
- 2:12c38a710982
- Child:
- 4:3cdbefbd2409
- Commit message:
- added readline. it is not debugged yet
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 14:01:24 2013 +0000
+++ b/btbee.cpp Wed Feb 05 10:32:04 2014 +0000
@@ -49,3 +49,23 @@
return 1;
}
+/* Read from the serial as long as no LF (\n) char has been read.
+* WARNING: This will block your program if no LF is received.
+* 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_line(char * arr, const int len, int * chars_read){
+int pos=0;
+do
+{
+ while(!readable()){}
+ if (pos==len){return 0;}
+ arr[pos]=getc();
+ pos++;
+ *chars_read = pos;
+}
+while (!(arr[pos]=='\n'));
+return 1;
+}
--- a/btbee.h Thu May 16 14:01:24 2013 +0000 +++ b/btbee.h Wed Feb 05 10:32:04 2014 +0000 @@ -14,6 +14,7 @@ void factory_baud(void); void default_baud(void); int read_all(char*,const int, int*); + int read_line(char*,const int, int*); protected: DigitalOut reset_out;
