Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

FIT or CSV for live data? 

Rank

Total Posts: 6

Joined 2015-02-05

PM

FIT or CSV for live data? Which solution is better for recording live data?

I'm afraid of corrupted fit files if the application crashes.
As far as I know, the header is saved while the file is closing.

I want to write to the same file again after restarting the application.      
RankRankRankRank

Total Posts: 370

Joined 2012-06-27

PM

FIT files are used for real time logging in many systems. You just need to ensure that you write the header and CRC with every update to the file contents if you are concerned about crashes.

You will have to ensure that your system cannot crash while the header and CRC are being updated, that this case is rare enough, or implement a system for identifying and recovering from this case.

Note: There are a number of online tools that help recover FIT files with some form of corruption.

Ian      

Signature

Ian Haigh

Rank

Total Posts: 6

Joined 2015-02-05

PM

Thanks for the answer.
I do not know if we are talking about the same thing.

The library code for android removes the file when it is reopened.
I haven't found a way to safely add records to an existing file.

public FileEncoder(File var1ProtocolVersion var2{
        this
.version var2;
        
this.validator = new ProtocolValidator(var2);
        
this.open(var1);
    
}

    
public void open(File var1{
        var1
.delete();
        
this.crc16 = new CRC16();
        
this.file var1;
        
this.writeFileHeader();

        try 
{
            this
.out = new CheckedOutputStream(new FileOutputStream(this.filetrue), this.crc16);
        
catch (IOException var3{
            
throw new FitRuntimeException(var3);
        
}
    } 



I don't even want to suggest users to repair fit files in online tools,
without the possibility to continue training.
     
Rank

Total Posts: 6

Joined 2015-02-05

PM

Crashes don't happen, but I want to protect users from them. I take their data very seriously.
     
RankRankRankRank

Total Posts: 370

Joined 2012-06-27

PM

The code you posted implements only basic file management. To get more advanced file management you are going to need to implement your own file manager (or find a library with more advanced features) that allows files to be re-opened, updates the header and CRC after each new message is written, and detects/recovers from crashes.

Ian      

Signature

Ian Haigh