An alternative Serial Library for Arduino 1.0

There is no point in limiting buffers to a power of two. You don't need a divide to maintain the index for a ring buffer.

A power of two is very coarse for large buffers on a 328. 512 vs 1024 for example.

Also these functions are small and fast so I don't see a point in limiting the ring buffer indices to 8-bits.

Here are my get and put functions for the next version of SerialPort:

//------------------------------------------------------------------------------
/** get the next byte
 * \param[in] b location for the returned byte
 * \return true if a byte was returned or false if the ring buffer is empty
 */
bool SerialRingBuffer::get(uint8_t* b) {
  size_t t = tail;
  if (head == t) return false;
  *b = buf[t++];
  tail = t < size ? t : 0;
  return true;
}
//------------------------------------------------------------------------------
/** put a byte into the ring buffer
 * \param[in] b the byte
 * \return true if byte was transfered or false if the ring buffer is full
 */
bool SerialRingBuffer::put(uint8_t b) {
  size_t h = head;
  // OK to store here even if ring is full
  buf[h++] = b;
  if (h >= size) h = 0;
  if (h == tail) return false;
  head = h;
  return true;
}