tormoder / fit

A Go package for decoding and encoding Garmin FIT files
MIT License
243 stars 42 forks source link

include multi-byte bit in base type #66

Closed dudanian closed 1 year ago

dudanian commented 2 years ago

The most-significant bit in the base type field is set on data types which are larger than 1 byte. While this bit isn't terribly important when parsing a fit file (and is all but ignored currently), it should still be set when exporting a fit file to prevent writing invalid base data types.

The updated values can be found here under Table 7. FIT Base Types and Invalid Values

dudanian commented 2 years ago

I updated this to use internal structs and a switch to group the data instead of a bunch of parallel arrays. I found this to be much easier to reason through. I also replaced the bit logic with a decompress func so we don't deal with semi-valid Base variables. It should hold the same nil safety as the previous work (the previous code would index OOB error on invalid usage and this will nil pointer except on invalid usage). This latest commit is a much bigger refactor than before and am open to reverting it.

tormoder commented 2 years ago

Hi. Thanks for looking into this. I'll try to take a look soon.

May I ask you to split the two approaches into two separate PRs?

cloudlena commented 1 year ago

@tormoder, have you already had time to look into these PRs? I think, they would actually fix https://github.com/tormoder/fit/issues/69 :rocket:

tormoder commented 1 year ago

Superseded by #67.