From ee6e6fecc40bd9c1c1112655f1822bbc18856380 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 8 Dec 2022 11:46:19 +0000 Subject: [PATCH] Exrail startup diags and Wifi don't trust available() call. --- EXRAIL2.cpp | 2 ++ WifiInterface.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index d72f8b0..e72e057 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -196,6 +196,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) { case OPCODE_IFNOT: { int16_t pin = (int16_t)operand; if (pin<0) pin = -pin; + DIAG(F("EXRAIL input vpin %d"),pin); IODevice::configureInput((VPIN)pin,true); break; } @@ -205,6 +206,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) { case OPCODE_IFGTE: case OPCODE_IFLT: case OPCODE_DRIVE: { + DIAG(F("EXRAIL analog input vpin %d"),(VPIN)operand); IODevice::configureAnalogIn((VPIN)operand); break; } diff --git a/WifiInterface.cpp b/WifiInterface.cpp index 9386e83..8fd4a25 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -341,9 +341,14 @@ void WifiInterface::ATCommand(HardwareSerial * stream,const byte * command) { while(stream->available()) stream->read(); // Drain serial input first bool startOfLine=true; while(true) { - while (wifiStream->available()) stream->write(wifiStream->read()); + while (wifiStream->available()>=0) { + int cx=wifiStream->read(); + if (cx<=0) break; + stream->write(cx); + } if (stream->available()) { int cx=stream->read(); + if (cx<0) continue; // A newline followed by !!! is an exit if (cx=='\n' || cx=='\r') startOfLine=true; else if (startOfLine && cx=='!') break;