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.
Fork of ATParser by
Revision 4:38acbd6f9d9e, committed 2015-07-17
- Comitter:
- geky
- Date:
- Fri Jul 17 16:38:44 2015 +0000
- Parent:
- 3:32915b9467d2
- Child:
- 5:26bc9255b751
- Commit message:
- Exposed the underlying putc/getc methods for collecting raw data
Changed in this revision
| ATParser.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ATParser.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ATParser.cpp Fri Jul 17 16:31:58 2015 +0000
+++ b/ATParser.cpp Fri Jul 17 16:38:44 2015 +0000
@@ -26,7 +26,7 @@
// getc/putc handling with timeouts
-int ATParser::_putc(char c) {
+int ATParser::putc(char c) {
Timer timer;
timer.start();
@@ -39,7 +39,7 @@
}
}
-int ATParser::_getc() {
+int ATParser::getc() {
Timer timer;
timer.start();
@@ -52,7 +52,7 @@
}
}
-void ATParser::_flush() {
+void ATParser::flush() {
while (_serial->readable())
_serial->getc();
}
@@ -61,13 +61,13 @@
// getline/putline handling with timeouts/bounds checking
bool ATParser::_putline(const char *line) {
for (int i = 0; line[i]; i++) {
- if (_putc(line[i]) < 0)
+ if (putc(line[i]) < 0)
return false;
}
// Finish with newline
for (int i = 0; _delimiter[i]; i++) {
- if (_putc(_delimiter[i]) < 0)
+ if (putc(_delimiter[i]) < 0)
return false;
}
@@ -82,7 +82,7 @@
int i = 0;
while (i < size) {
- int c = _getc();
+ int c = getc();
if (c < 0)
return false;
@@ -107,7 +107,7 @@
va_list args;
va_start(args, response);
- _flush();
+ flush();
// Create and send command
if (command) {
--- a/ATParser.h Fri Jul 17 16:31:58 2015 +0000
+++ b/ATParser.h Fri Jul 17 16:38:44 2015 +0000
@@ -37,14 +37,7 @@
// Parsing information
const char *_delimiter;
- int _delim_size;
-
- // Helper methods for putc/getc with timeout
- int _putc(char c);
- int _getc();
-
- // Flush used to clear serial connection
- void _flush();
+ int _delim_size;
// Helper methods for reading/writing lines with
// timeout and buffer limitations
@@ -126,5 +119,25 @@
* @return true only if response is successfully matched
*/
bool command(const char *command, const char *response, ...);
+
+ /**
+ * Write a single byte to the underlying stream
+ *
+ * @param c The byte to write
+ * @return The byte that was written or -1 during a timeout
+ */
+ int putc(char c);
+
+ /**
+ * Get a single byte from the underlying stream
+ *
+ * @return The byte that was read or -1 during a timeout
+ */
+ int getc();
+
+ /**
+ * Flushes the underlying stream
+ */
+ void flush();
};
