Hi,
I'm debugging a ruby gem which is used to generate and parse FIT-files;
https://github.com/scrapper/fit4ruby
I'm reading the Flexible and Interoperable Data Transfer Protocol Rev 2.2 document and specifically section 3.3.
The algorithm how to calculate the CRC is specified and has no uncertainties though the documentation does not mention explicitly over which bytes it should be applied. I have written several tests to verify the code in fit4ruby and when calculating the CRC for the 14 byte header the algorithm should obviously be iterated over the 12 header bytes, byte 0 to 11. And compared to byte 12 and 13 to check correctness. That works fine. And then calculating the file CRC over bytes 14 to end of file minus the 2 CRC bytes also seems correct.
But what about the two cases when there is a 12 byte sized header or the 14 byte header has CRC in the header set to 0000? It seems that the correct way to calculate the file CRC in these cases is over the whole file, from byte 0 to file size minus 2.
The later is not specified in the specification though analysing the SDK example files indicate this is the case and it makes sense. It would be great if the specification could be clarified in regards to this.
Best Regards,
Karl-Petter