the function def returns an int, but the function actually returns an unsigned char (at least when you care about it, when theres nothing to read i guess you get the full int). shouldnt this return an unsigned char all the time? save some memory?
int serialRead()
{
// if the head isn't ahead of the tail, we don't have any characters
if (rx_buffer_head == rx_buffer_tail) {
return -1;
} else {
unsigned char c = rx_buffer[rx_buffer_tail];
rx_buffer_tail = (rx_buffer_tail + 1) % RX_BUFFER_SIZE;
return c;
}
}