pic32/cores/pic32/HardwareSerial.cpp
/* ------------------------------------------------------------ */
/***	HardwareSerial::read
**
**	Parameters:
**		none
**
**	Return Value:
**		next character from the receive buffer
**
**	Errors:
**		returns -1 if no characters in buffer
**
**	Description:
**		Return the next character from the receive buffer and remove
**		it from the buffer, or -1 if no characters are available in
**		the buffer.
*/
:read

none

Return Value:
next character from the receive buffer

1 if no characters in buffer

Return the next character from the receive buffer and remove
it from the buffer, or -1 if no characters are available in
the buffer.
: read none Return Value : next character from the receive buffer 1 if no characters in buffer Return the next character from the receive buffer and remove it from the buffer or - 1 if no characters are available in the buffer .
int HardwareSerial::read(void)
{
	unsigned char theChar;
	if (rx_buffer.head == rx_buffer.tail)
	{
		return -1;
	}
	else
	{
		theChar			= rx_buffer.buffer[rx_buffer.tail];
		rx_buffer.tail	= (rx_buffer.tail + 1) % RX_BUFFER_SIZE;
		return (theChar);
	}
}
int HardwareSerial :: read ( void ) { unsigned char theChar ; if ( rx_buffer . head == rx_buffer . tail ) { return -1 ; } else { theChar = rx_buffer . buffer [ rx_buffer . tail ] ; rx_buffer . tail = ( rx_buffer . tail + 1 ) % RX_BUFFER_SIZE ; return ( theChar ) ; } }
HardwareSerial::read
HardwareSerial :: read
// if the head isn't ahead of the tail, we don't have any characters