Skip to content

Encoder: new file not readable #83

Open

Description

@svergin

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

Activity

  1. KARTOFF8xE commented on Dec 2, 2023

    @KARTOFF8xE

    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.

  2. rosvit commented on May 22, 2024

    @rosvit

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions