An alternative Serial Library for Arduino 1.0

fat16lib:
There could very well be bugs so let me know if you find a slowdown problem. I only put two days into this so far. I haven't done much testing.

I put this code out so I could get comments while I am early in development. I really appreciate suggestions like robtillaart's suggestion to add parity, character size, and stop-bit options. Also to return error information for parity, framing, receiver overruns, and buffer overruns.

OK. It's taken a while to isolate the problem. It seems that creating the second serial port is causing all the problems. This simple program demonstrates the problem. I've no idea what's causing it but if you don't add the SerialPort<1, 16, 16> but it's fine. No idea if the parameters are important. Each loop should report either 0us or 4us. However after the first loop, it reports 156us each time. I'm guessing something in an interrupt is eating all my cycles.

#include <SerialPort.h>

static SerialPort<0, 0, 256> serialPort;
static SerialPort<1, 16, 16> serialPort1;

void setup(void)
{
	SerialPort<0, 0, 256> serialPort;

	serialPort.begin(115200);
	serialPort1.begin(115200);
	for (int route = 0; route < 11; route++)
	{
		uint32_t start, stop;

		start = micros();
		stop = micros();
		serialPort.print(stop - start, DEC);
		serialPort.println("us");
		delay(400);
	}
}

void loop(void)
{
}

Hope that helps.

Iain