FIFO protection (#1285)
* Adds protection around pushing packets to FIFO
This ensures that there is enough room for the entire packet in the FIFO otherwise it just drops the packet.
Previously it would flush the FIFO on whichever push caused the overflow and the FIFO would have partial packets.
* Add protection around pushing to the UART fifo
Set the max number of bytes that we can push in one iteration to the minimum of period bytes or Serial.availableForWrite
* Rework ensure method
- old ensure is called available
- new ensure pops "packets" from the head until available is true
* Change length params to unsigned
Can't push or pop a -ve number of elements ;-)
* And fixed the calls to FIFO to avoid the casts