A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/esp8266/Arduino/issues/8452 below:

default implementation for buffered Stream.read only reads every second byte · Issue #8452 · esp8266/Arduino · GitHub

The current Stream::read (uint8_t* buffer, size_t maxLen) provides a standard implementation for writing a stream to a buffer.
It uses the virtual int method Stream::read() to read the stream byte by byte until no more bytes are available.

However, it calls read() twice in each loop. This results in only every 2nd byte actually being read into the destination buffer, as the read() method will always return the next byte in the stream.
At least that is my understanding of how the read() method of streams is supposed to work.

The lines of code involved:

int Stream::read (uint8_t* buffer, size_t maxLen) { IAMSLOW(); size_t nbread = 0; while (nbread < maxLen && available()) { int c = read(); if (c == -1) break; buffer[nbread++] = read(); } return nbread;

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4