wjwwood/serial — pull request #43 by mikepurvis (2013-10-10 20:52:22+00:00)
Title: Timespec refactor

This PR addresses #42. Summary:
- Introduce a new unix-timespec.h header, which includes timespec operators for +, -, * by int, min, and conversion from millis. Rationale for new file is logical separation and better testability (though no tests at this point).
- Cache the timeout values as timespecs in the SerialImpl, as that's the form in which they are exclusively used.
- Call setTimeout() with a default Timeout obj from the constructor, to initialize the timespec caches to 0.
- Simplify the timing logic in read and write methods to be based both around a fixed endtime, rather than timeout which is adjusted multiple times.
- Introduce an available() check in read, to avoid going to the first select() if data is already waiting. This is important for devices which deliver a larger amount of data (eg, 5000+ bytes/sec), and is independent of the select/pselect switchover.

Testing done has been against the um6 driver in Ubuntu Raring. The um6 driver uses both read and write.

A followup will introduce the sleepByteTimes() and waitAvailable() functions to the external API.