TimedRead is private in Stream.h for Teensy 4

RichardFerraro

Well-known member
In Arduino\hardware\teensy\avr\cores\teensy4\Stream.h
the following are private
private:
char read_error;
int timedRead();
int timedPeek();
int peekNextDigit();

I am using <ArduinoHttpClient.h> library which requires these to be public.
I have changed "private" to "public" and I can compile/run.

Any chance this can be changed in future TeensyDuino releases (I am using 1.54)?

Thanks
 
@Paul - wonder if we should make minor change to make more compatible with Arduino.

As mentioned here, the private methods are protected in most of the other plaforms.


That is I checked: AVR, SAM, SAMD and they all have:

Code:
// This enumeration provides the lookahead options for parseInt(), parseFloat()
// The rules set out here are used until either the first valid character is found
// or a time out occurs due to lack of input.
enum LookaheadMode{
    SKIP_ALL,       // All invalid characters are ignored.
    SKIP_NONE,      // Nothing is skipped, and the stream is not touched unless the first waiting character is valid.
    SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped.
};

#define NO_IGNORE_CHAR  '\x01' // a char not found in a valid ASCII numeric field

class Stream : public Print
{
  protected:
    unsigned long _timeout;      // number of milliseconds to wait for the next char before aborting timed read
    unsigned long _startMillis;  // used for timeout measurement
    int timedRead();    // read stream with timeout
    int timedPeek();    // peek stream with timeout
    int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout

Also it looks like changes in the parseInt, parseFloat:

The current ones that Teensy has are now marked as protected on Arduino.
And new ones created:
Code:
  long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
  // returns the first valid (long) integer value from the current position.
  // lookahead determines how parseInt looks ahead in the stream.
  // See LookaheadMode enumeration at the top of the file.
  // Lookahead is terminated by the first character that is not a valid part of an integer.
  // Once parsing commences, 'ignore' will be skipped in the stream.

  float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
  // float version of parseInt
 
Back
Top