qdot/libfitbit — pull request #18 by marcushall42 (2012-01-15 00:23:55+00:00)
Title: Create protocol::_recieve_message() with protocol level operations above libusb

The bulk of this change is to create a _receive_message() method at the protocol level that performs framing and checksum validation. The underlying libusb _receive() method is invoked as needed to retrieve data which may contain multiple packets or partial packets. The SYNC characters (ANT protocol says a4 or a5 is valid sync) are used to determine the beginning of a packet. Any data beyond the end of the current packet is saved for the next invocation. Timeouts from libusb are tolerated, but after four timeouts any packets received already are processed and any other data is discarded.

I am submitting this for consideration. It works for me.