From f674b64310eafc705e2ffaf159adccbc7df0a785 Mon Sep 17 00:00:00 2001 From: Don Rowe Date: Sun, 12 Aug 2018 19:41:49 -0700 Subject: [PATCH] Make readline function compatible with screen line endings --- examples/FONAtest/FONAtest.ino | 7 +++---- examples/FONAtest_KEY_mod/FONAtest_KEY_mod.ino | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/FONAtest/FONAtest.ino b/examples/FONAtest/FONAtest.ino index 0f72568..cd157d1 100644 --- a/examples/FONAtest/FONAtest.ino +++ b/examples/FONAtest/FONAtest.ino @@ -862,12 +862,11 @@ uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout) { //Serial.print(c, HEX); Serial.print("#"); Serial.println(c); - if (c == '\r') continue; - if (c == 0xA) { - if (buffidx == 0) // the first 0x0A is ignored + if (c == 0xA || c == 0xD) { + if (buffidx == 0) // the first 0x0A or 0x0D is ignored continue; - timeout = 0; // the second 0x0A is the end of the line + timeout = 0; // the second 0x0A or 0x0D is the end of the line timeoutvalid = true; break; } diff --git a/examples/FONAtest_KEY_mod/FONAtest_KEY_mod.ino b/examples/FONAtest_KEY_mod/FONAtest_KEY_mod.ino index 775c72d..ed469b9 100644 --- a/examples/FONAtest_KEY_mod/FONAtest_KEY_mod.ino +++ b/examples/FONAtest_KEY_mod/FONAtest_KEY_mod.ino @@ -885,12 +885,11 @@ uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout) { //Serial.print(c, HEX); Serial.print("#"); Serial.println(c); - if (c == '\r') continue; - if (c == 0xA) { - if (buffidx == 0) // the first 0x0A is ignored + if (c == 0xA || c == 0xD) { + if (buffidx == 0) // the first 0x0A or 0x0D is ignored continue; - timeout = 0; // the second 0x0A is the end of the line + timeout = 0; // the second 0x0A or 0x0D is the end of the line timeoutvalid = true; break; }