dtcooper / python-fitparse

Python library to parse ANT/Garmin .FIT files
http://pythonhosted.org/fitparse/
MIT License
738 stars 183 forks source link

Hitting "Invalid .FIT File Header" on FR245 Music and sometimes on FR210 #112

Closed jmrnilsson closed 3 years ago

jmrnilsson commented 4 years ago

Should I switch to the egg? Maybe the SDK is old on the PYPI package.

I hit the following failure state on all my Garmin Forerunner 245 Music, and some of my Garmin Forerunner 210 fit files. Unknown if Garmin 245 Music previously had this issue. But there has been firmware updates for this device recently.

        if header_data[8:12] != b'.FIT':
            raise FitHeaderError("Invalid .FIT File Header")

https://github.com/dtcooper/python-fitparse/blob/798035875da1692e3165cc15319380967fa6b812/fitparse/base.py#L105

Version: Pypi fitparse==1.1.0

Thanks for the excellent library 🥇. These binary formats are a real head-scratchers.

dlenski commented 3 years ago

I hit the following failure state on all my Garmin Forerunner 245 Music, and some of my Garmin Forerunner 210 fit files. Unknown if Garmin 245 Music previously had this issue.

Can you share some .fit binaries from these devices? Even a 2-second-long empty activity should suffice.

        if header_data[8:12] != b'.FIT':
           raise FitHeaderError("Invalid .FIT File Header")

This header is a very basic fundamental part of the .fit format, and I don't understand how it could diverge on such a common Garmin device. :man_shrugging:

jmrnilsson commented 3 years ago

Yeah. I suppose. Though I have some few things to reinstall. Give me a few days.

jmrnilsson commented 3 years ago

I’ve been looking into this. But with a lot of changes in my own code and different version of fitparse. It doesn’t seem like I have this issue anymore.

You could probably close this issue for now, and I can repost if anything shows again.

TL;DR I’m did some weird work around the file handle since I want to use streaming requests behind Flask. This might very well have messed with encoding or something else.