Closed
Description
In SoftwareSerial.h the ring buffer is defined as:
This is a signed quantity. If a byte is received where the high bit is set, this causes unexpected and incorrect behavior.
This is SoftwareSerial::read()
:
ArduinoCore-renesas/libraries/SoftwareSerial/src/SoftwareSerial.cpp
Lines 328 to 335 in bba294b
It returns an int
, which is a signed quantity. Since get()
is returning a char
, which is also a signed quantity, if the highest bit in that byte is set all of the high-order bits in the int
that is returned will be set. Code that checks for the read value to be less than zero will fail.
Defining it instead as:
::RingBuffer<uint8_t> ringbuf;
fixes the problem and gives expected behavior.