Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 62cf4b6

Browse filesBrowse files
committed
Revert "Match return value to type in available()"
This reverts commit f40e471. Added an hint for the buffer sizes. See arduino#2057 Fixes arduino#2367
1 parent 58b6fd4 commit 62cf4b6
Copy full SHA for 62cf4b6

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed

‎hardware/arduino/cores/arduino/HardwareSerial.cpp

Copy file name to clipboardExpand all lines: hardware/arduino/cores/arduino/HardwareSerial.cpp
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
// using a ring buffer (I think), in which head is the index of the location
5454
// to which to write the next incoming character and tail is the index of the
5555
// 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.
5658
#if (RAMEND < 1000)
5759
#define SERIAL_BUFFER_SIZE 16
5860
#else
@@ -426,7 +428,7 @@ void HardwareSerial::end()
426428

427429
int HardwareSerial::available(void)
428430
{
429-
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;
430432
}
431433

432434
int HardwareSerial::peek(void)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.