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: ATParser MPL3115A2 mbed
Revision 3:59fbf4f41f69, committed 2018-04-06
- Comitter:
- csinders
- Date:
- Fri Apr 06 15:24:35 2018 +0000
- Parent:
- 2:9af94ceb9d37
- Child:
- 4:9235d082b6a3
- Commit message:
- Fixed the confirm ok, we are able to send input now
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 05 14:56:40 2018 +0000
+++ b/main.cpp Fri Apr 06 15:24:35 2018 +0000
@@ -13,32 +13,38 @@
confirm that operation has succeeded
*/
int confirmOK() {
+ // Wait until device has a response
while (!device.readable()) {
wait_ms(100);
}
int bufferSize = 100;
char buf[bufferSize];
- int i = 0;
- for (i = 0; i < bufferSize; i++) {
+ int i = 0;
+ for (i = 0; i < bufferSize; i++) {
buf[i] = 0;
}
i = 0;
- // Wait until device has a response
+
+ //Read message from device into buffer
for (i = 0; device.readable(); i++) {
buf[i] = device.getc();
+ if (buf[i] == '\n') {
+ // Read new line so check to see if we got an OK or Error
+ // else keep reading til we get one
+ if (!strncmp("OK",buf,2)) {
+ //pc.printf("I compared against %s and got OK\r\n",buf);
+ return 1;
+ } else if (!strncmp("ERROR",buf,5)) {
+ //pc.printf("I compared against %s and got ERROR\r\n",buf);
+ return 0;
+ }
+ return confirmOK();
+ }
if (i >= bufferSize) {
return 0;
}
}
- pc.printf("I got %s from the device\r\n", buf);
- wait_ms(100);
- if (strncmp("OK",buf,2)) {
- return 1;
- } else if (strncmp("ERROR",buf,5)) {
- return 0;
- } else {
- confirmOK();
- }
+ return 0;
}
/* Sends a message to the xDot
Messages are expected to end in \n so that an OK confirmation will be