Cosa: An Object-Oriented Platform for Arduino programming

sirhax:
Please forgive my ignorance, but may I ask why the design principle is that the additional UART instances/buffers are not pre-allocated? Is it to save memory?

Great questions! I want to leave as much memory as possible to applications. Preallocation of buffers is actually difficult as it depends on the amount of "speed adjustment" needed. The buffer should be as large as possible to allow the application to continue processing. But small enough to leave as much memory as possible. The UART can be viewed as an extra processor. The goal is to get as many of the AVR hardware resources to run in parallel with the processor core.

An example: for a given output stream (bytes per second, in burst) the buffer size depends on the speed of the transmission (baud-rate). The faster the baud-rate the shorter the buffer for a fixed output rate but at least the size of a burst. If the buffer is too small the application will stall due to waiting on the UART.

Nearly all memory allocation in Cosa is configurable and/or input parameters as the IOBuffer's.

Cheers!