fit-0.5.1: FIT file decoder

CopyrightCopyright 2014-2015, Matt Giles
LicenseModified BSD License (see LICENSE file)
Maintainermatt.w.giles@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Fit.Internal.FitFile

Description

 

Synopsis

Documentation

data Fit Source

A FIT file consists of a header and a collection of messages.

Constructors

Fit 

Instances

data FitHeader Source

The FIT file header

Constructors

FH 

Fields

fhSize :: !Word8

Size of the header in bytes. Will always be 12 or 14, based on presence of the CRC

fhProtocolVersion :: !Word8

Protocol version number

fhProfileVersion :: !Word16

Profile version number

fhDataSize :: !Word32

Combined length of the FIT messages, in bytes

fhDataType :: ByteString

File tag, should always be ".FIT"

fhCrc :: !(Maybe Word16)

Optional checksum for header contents

Instances

data Message Source

There are two kinds of FIT messages:

  • Definition messages set the structure for messages of a particular local message type
  • Data messages contain the actual information, according to the structure given by a definition message.

Instances

data MessageDefinition Source

A MessageDefinition for a local message type (LMT) determines how future data messages with that LMT are decoded. LMTs can be re-used: a data message with LMT n will use the most recent message definition for LMT n.

Constructors

MessageDef 

Fields

defLocalType :: !LocalMessageType

The local message type being defined

defGlobalType :: !Int

The global message type this LMT will refer to. Must be a valid mesg_num value from the FIT profile

defArch :: !Arch

The architecture this messages with this LMT will use for multi-byte values (little- or big-endian)

defFields :: [FieldDef]

Definitions for the fields messages with this LMT will contain

data FieldDef Source

Defines the structure for a single field in a message

Constructors

FieldDef 

Fields

fdNum :: !Int

The field number. The interpretation of the field number depends on the global message type and is found in the FIT profile

fdSize :: !Int

The size, in bytes, of the field's contents. This will be a multiple of the base type size. In a singleton field this size will be the same as the base type size. In an array field it will be some multiple of the base type size.

fdBaseType :: !BaseType

The FIT base type of values in the field

Instances

data Field Source

A single field in a data message, containing the field number and the value(s)

Instances

data Value Source

Singleton values. There is a Value constructor for each BaseType constructor. The wrapped value in these constructors corresponds to the specific format used in the FIT file, for example an enum in FIT is stored as an 8-bit unsigned int (ie a Word8). The primary exception to this is using Text for string values.

Constructors

EnumValue !Word8 
SInt8Value !Int8 
UInt8Value !Word8 
SInt16Value !Int16 
UInt16Value !Word16 
SInt32Value !Int32 
UInt32Value !Word32 
StringValue Text

A string in FIT is a null-terminated arrays of UTF-8 code units, but Text is used here instead

Float32Value !Float 
Float64Value !Double 
UInt8ZValue !Word8 
UInt16ZValue !Word16 
UInt32ZValue !Word32 
ByteValue !Word8 

Instances

data Array Source

Array values use similar constructors to singleton values. However, there is no constructor for arrays of strings, which seem to be unused in FIT.

Instances

data MessageHeader Source

Each message has a header that primarily determines whether the message is a definition or data message. If the message uses a compressed timestamp header, the header also contains the compressed time offset.

Instances

newtype LocalMessageType Source

A local message type is a 4 bit unsigned integer

Constructors

LMT 

Fields

unLmt :: Int8
 

mkLocalMessageType :: (Integral a, Bits a) => a -> LocalMessageType Source

Only the lower 4 bits of the integer are used to construct a LocalMessageType

unLocalMessageType :: Integral a => LocalMessageType -> a Source

Unwrap a LocalMessageType. The resulting integer will be between 0 and 15

newtype TimeOffset Source

A time offset is 5 bits

Constructors

TO 

Fields

unTo :: Word8
 

Instances

mkTimeOffset :: (Integral a, Bits a) => a -> TimeOffset Source

Only the lower 5 bits of the number are used

newtype Timestamp Source

Constructors

Timestamp 

Fields

unTimestamp :: Word32
 

data BaseType Source

The different types that FIT uses for field values

Instances

btSize :: BaseType -> Int Source

Get the size in bytes for a single value of the given base type