We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58b6fd4 commit 62cf4b6Copy full SHA for 62cf4b6
hardware/arduino/cores/arduino/HardwareSerial.cpp
@@ -53,6 +53,8 @@
53
// using a ring buffer (I think), in which head is the index of the location
54
// to which to write the next incoming character and tail is the index of the
55
// location from which to read.
56
+// NOTE: a "power of 2" buffer size is reccomended to dramatically
57
+// optimize all the modulo operations for ring buffers.
58
#if (RAMEND < 1000)
59
#define SERIAL_BUFFER_SIZE 16
60
#else
@@ -426,7 +428,7 @@ void HardwareSerial::end()
426
428
427
429
int HardwareSerial::available(void)
430
{
- return (int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
431
+ return ((unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail)) % SERIAL_BUFFER_SIZE;
432
}
433
434
int HardwareSerial::peek(void)
0 commit comments