Skip to content

Commit

Permalink
Revert "Match return value to type in available()"
Browse files Browse the repository at this point in the history
This reverts commit f40e471.
Added an hint for the buffer sizes.

See arduino#2057
Fixes arduino#2367
  • Loading branch information
cmaglie committed Oct 21, 2014
1 parent 58b6fd4 commit 62cf4b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hardware/arduino/cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
// using a ring buffer (I think), in which head is the index of the location
// to which to write the next incoming character and tail is the index of the
// location from which to read.
// NOTE: a "power of 2" buffer size is reccomended to dramatically
// optimize all the modulo operations for ring buffers.
#if (RAMEND < 1000)
#define SERIAL_BUFFER_SIZE 16
#else
Expand Down Expand Up @@ -426,7 +428,7 @@ void HardwareSerial::end()

int HardwareSerial::available(void)
{
return (int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
return ((unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail)) % SERIAL_BUFFER_SIZE;
}

int HardwareSerial::peek(void)
Expand Down

0 comments on commit 62cf4b6

Please sign in to comment.