Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder: new file not readable #83

Open
svergin opened this issue Nov 3, 2023 · 2 comments
Open

Encoder: new file not readable #83

svergin opened this issue Nov 3, 2023 · 2 comments

Comments

@svergin
Copy link

svergin commented Nov 3, 2023

I've read a FIT file and modified the data. After that I wrote it to disc:

`func CreateTestFile() error {
testFile := filepath.Join("c:\", "dev", "fit", "i26475458.fit")
testData, err := os.ReadFile(testFile)
if err != nil {
return err
}

r := bytes.NewReader(testData)
fitfile, err := fit.Decode(r)
if err != nil {
	return err
}

activity, err := fitfile.Activity()
if err != nil {
	return err
}

for _, rec := range activity.Records {
	rec.Speed = 0
	rec.Distance = 0
}

fo, err := os.Create("c:\\dev\\fit\\output.fit")

defer fo.Close()
w := bufio.NewWriter(fo)

err = fit.Encode(w, fitfile, binary.LittleEndian)
if err != nil {
	return err
}
return nil

}
`

After that an error appears while reading it the same way as above:

error parsing file CRC: unexpected EOF

@KARTOFF8xE
Copy link

KARTOFF8xE commented Dec 2, 2023

Same Issue right here.

I also tried to CheckIntegrity() but got the same error IF the bool-arg is set to false. Otherwise no Error.

@rosvit
Copy link

rosvit commented May 22, 2024

I ran into this issue, too. Reading newly encoded FIT file in FIT File Viewer shows that file produced by this library is 2 bytes shorter than expected:

Fatal error: FIT Runtime Error end of stream at byte 356954
There were issues decoding this file
The file is too short: Expected 356,956 bytes, got 356,954 bytes. The file was probably truncated while downloading or copying.

Decoding using fit.Decode produces same error as mentioned above:

error parsing file CRC: unexpected EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants