Open
Description
HardwareSerial/SoftwareSerial::read() return a byte where the functions are defined to return an int. The implicit conversion from "unsigned char/uint8_t" to int returns 0xFFAA (= -86) for the received byte 0xAA.
The function Stream::findMulti() then tests the integer returned by Stream::timedRead() with "c < 0" instead of "c == -1" to distinguish between a received byte and -1 for still nothing available on the stream.
Therefore the function Stream.find() comes back with -1 after timeout, although read() received the byte 0xAA.
It took a lot of time to find out the reason why I didn't found the start byte 0xAA on the stream from my MP3 module response.
Metadata
Metadata
Assignees
Labels
Related to the code for the standard Arduino APIRelated to the code for the standard Arduino APIThe Arduino core library's Print and Stream classesThe Arduino core library's Print and Stream classes