#fit #sport #generated #reading #decoding #devices #message

fit-sdk

A small crate used for reading and decoding FIT files generated by sports devices

1 unstable release

0.1.0 Mar 31, 2019

#19 in #fit

MIT license

46KB
829 lines

Fit

Fit is a small crate used for reading and decoding FIT files generated by various sports devices. Currently it has only been designed specifically to read files produced by Garmin Edges 1000 and 520, and a Wahoo Elemnt. It will probably mostly work out of the box with other file sources, but will probably not work 100% perfectly unless it's a Garmin cycling computer.

The API currently is extremely basic with essentially just one method which produces an iterator which yields a stream of Message structs.

Breaking change!

Starting with v0.5 this crate delivers an iterator of Message rather than a struct containing a Vec<Message>.

Installation

[dependencies]
fit = "0.5"

Usage

extern crate fit;

use std::path::PathBuf;
use fit::Fit;

fn main() {
    let filepath = PathBuf::from("fits/2913547417.fit");
    let f = Fit::new(&filepath);
    for m in f {
	println!("Read a message of type {}", m.kind);
    }
}

A typical Message will look something like this:

Message {
  kind: Record,
  values: [
    DataField { field_num: 253, value: Time(1480856114) },
    DataField { field_num: 0,   value: F32(57.710945)   },
    DataField { field_num: 1,   value: F32(11.9945755)  },
    DataField { field_num: 5,   value: U32(1151)        },
    DataField { field_num: 29,  value: U32(0)           },
    DataField { field_num: 2,   value: U16(2394)        },
    DataField { field_num: 6,   value: U16(0)           },
    DataField { field_num: 7,   value: U16(0)           },
    DataField { field_num: 61,  value: U16(2234)        },
    DataField { field_num: 66,  value: I16(442)         },
    DataField { field_num: 3,   value: U8(113)          },
    DataField { field_num: 13,  value: I8(21)           }
  ],
  dev_values: None
}

A Value enum is a simple wrapper around most rust primitive types, such as u16 or i64 or f32.

Some things to watch out for:

  • speed is recorded as m/s, rather than kph.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/richardbrodie/fit-rs.

License

The gem is available as open source under the terms of the MIT License.

No runtime deps

~200KB