update condition to avoid reading an extra character after len characters have been read

Signed-off-by: Benjamin Cabé <benjamin@eclipse.org>
This commit is contained in:
Benjamin Cabé 2016-12-20 10:15:50 +01:00
parent 5ba5ccb712
commit 192c9664b2

View file

@ -356,7 +356,7 @@ int MicroBitUARTService::read(uint8_t *buf, int len, MicroBitSerialMode mode)
{
int c;
while((c = getc(mode)) >= 0 && i < len)
while(i < len && (c = getc(mode)) >= 0)
{
buf[i] = c;
i++;