From d84b4798d545de846f3ac6870459476fa89a4872 Mon Sep 17 00:00:00 2001 From: martinwork Date: Sun, 26 May 2019 12:30:48 +0100 Subject: [PATCH] Stop MicroBitSerial::read(ASYNC) dropping bytes Fixes #441 --- source/drivers/MicroBitSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/drivers/MicroBitSerial.cpp b/source/drivers/MicroBitSerial.cpp index 7fad4e00..7ac52cd0 100644 --- a/source/drivers/MicroBitSerial.cpp +++ b/source/drivers/MicroBitSerial.cpp @@ -646,7 +646,7 @@ int MicroBitSerial::read(uint8_t *buffer, int bufferLen, MicroBitSerialMode mode if(mode == ASYNC) { - while((temp = getChar(mode)) != MICROBIT_NO_DATA && bufferIndex < bufferLen) + while(bufferIndex < bufferLen && (temp = getChar(mode)) != MICROBIT_NO_DATA) { buffer[bufferIndex] = (char)temp; bufferIndex++;