1.3. records

class fitdecode.records.FitChunk(index, offset, bytes)
index

zero-based index of this frame in the file

offset

the offset at which this frame starts in the file

bytes

the frame itself as a bytes object

class fitdecode.records.FitHeader(header_size, proto_ver, profile_ver, body_size, crc, crc_matched, chunk)
frame_type = 1
header_size
proto_ver
profile_ver
body_size
crc

may be null

crc_matched
chunk

FitChunk or None (depends on keep_raw_chunks option)

class fitdecode.records.FitCRC(crc, matched, chunk)
frame_type = 2
crc
matched
chunk

FitChunk or None (depends on keep_raw_chunks option)

class fitdecode.records.FitDefinitionMessage(is_developer_data, local_mesg_num, time_offset, mesg_type, global_mesg_num, endian, field_defs, dev_field_defs, chunk)
frame_type = 3
is_developer_data
local_mesg_num
time_offset
mesg_type
global_mesg_num
endian
field_defs

list of FieldDefinition

dev_field_defs

list of DevFieldDefinition

chunk

FitChunk or None (depends on keep_raw_chunks option)

property name
property all_field_defs
class fitdecode.records.FitDataMessage(is_developer_data, local_mesg_num, time_offset, def_mesg, fields, chunk)
frame_type = 4
is_developer_data

Is this a “developer” message?

local_mesg_num

The local definition number of this message

time_offset

Time offset in case header was compressed. None otherwise.

def_mesg

FitDefinitionMessage

fields

list of FieldData

chunk

FitChunk or None (depends on keep_raw_chunks option)

property name

Message name

property global_mesg_num

The global definition number of this message

property mesg_type

The MessageType object this message is associated to

has_field(field_name_or_num)

Is the desired field present in this message?

field_name_or_num is the name of the field (str), or its definition number (int).

get_field(field_name_or_num, idx=0)

Get the desired FieldData object.

field_name_or_num is the name of the field (str), or its definition number (int).

idx is the zero-based index of the specified field among other fields with the same name/number. I.e. not the index of the field in the list of fields of this message. That is, idx=0 is the first field_name_or_num field found in this message.

idx is useful in case a message contains multiple fields with the same field_name_or_num.

get_fields(field_name_or_num)

Like get_field but yield every FieldData object matching field_name_or_num fields in this message - i.e. generator.

get_raw_value(field_name_or_num, *, idx=0, fallback=<object object>, raw_value=True, fit_type=None, py_type=<object object>)
get_value(field_name_or_num, *, idx=0, fallback=<object object>, raw_value=False, fit_type=None, py_type=<object object>)

Get the value (or raw_value) of a field specified by its name or its definition number (field_name_or_num), with optional type checking.

idx has the same meaning than for get_field.

fallback can be specified to avoid KeyError being raised in case no field matched field_name_or_num.

fit_type can be a str to indicate a given FIT type is expected (as defined in FIT profile; e.g. date_time, manufacturer, …), in which case TypeError may be raised in case of a type mismatch.

py_type can be a Python type or a tuple of types to expect (as passed to isinstance), in which case TypeError may be raised in case of a type mismatch.

raw_value can be set to a true value so that the returned value is field’s raw_value property instead of value. This does not impact the way fit_type and py_type are interpreted.

Special case: field_name_or_num can be None, in which case the field will be selected using idx only. In this case, idx is interpreted to be the zero-based index in the list of fields.

get_values(field_name_or_num, *, raw_value=False, fit_type=None, py_type=<object object>)

Like get_value but yield every value of all the fields that match field_name_or_num - i.e. generator.

It is not possible to specify a fallback value so KeyError will always be raised in case the specified field was not found.

The other arguments have the same meaning than for get_value.