Issue with checksum calculation
Using TFMini v1.8 device the frame size is 7. The code that calculates the checksum adds all positions that are less than frame size - 2. I found that the checksum was always 9 greater than the calculation. Position 5 is always 9 but not included in the calculation.
This caused the following error: TF Mini error: too many measurement attempts Last error: ERROR_SERIAL_BADCHECKSUM 65535 cm sigstr: 65535
After changing the calculation to include position 5 like so:
if (i < TFMINI_FRAME_SIZE-1) { checksum += frame[i]; }
instead of:
if (i < TFMINI_FRAME_SIZE-2) { checksum += frame[i]; }
Things are now working.
I'm not sure what the frame size is of other TF Devices. Are they different? Maybe older versions have a frame size of 8? Anyway, just wanted to report what I found.
Hmmm, that's very interesting. It's certainly possible that they've changed the protocol slightly in the latest revisions of their devices.
Would you like to submit a pull request that:
- Adds a version parameter passed to the class constructor, and some defines (e.g. VER_1_0, VER_1_8) for the version
- Performs the checksum calculation based on the version
- Includes the parameter in the example?