Skip to content

Commit 40ca58d

Browse files
author
Jenkins
committed
Garmin FIT SDK 21.194.0
Change-Id: Ib16468e10da779ef0c414825fa414ea4d5cc2180
1 parent 831d1fc commit 40ca58d

22 files changed

Lines changed: 46387 additions & 46367 deletions

README.md

Lines changed: 216 additions & 215 deletions
Large diffs are not rendered by default.

garmin_fit_sdk/__init__.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# __init__garmin_fit_sdk.py
2-
3-
###########################################################################################
4-
# Copyright 2025 Garmin International, Inc.
5-
# Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
6-
# may not use this file except in compliance with the Flexible and Interoperable Data
7-
# Transfer (FIT) Protocol License.
8-
###########################################################################################
9-
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
10-
# Profile Version = 21.188.0Release
11-
# Tag = production/release/21.188.0-0-g55050f8
12-
############################################################################################
13-
14-
15-
from garmin_fit_sdk.accumulator import Accumulator
16-
from garmin_fit_sdk.bitstream import BitStream
17-
from garmin_fit_sdk.crc_calculator import CrcCalculator
18-
from garmin_fit_sdk.decoder import Decoder
19-
from garmin_fit_sdk.fit import BASE_TYPE, BASE_TYPE_DEFINITIONS
20-
from garmin_fit_sdk.hr_mesg_utils import expand_heart_rates
21-
from garmin_fit_sdk.profile import Profile
22-
from garmin_fit_sdk.stream import Stream
23-
from garmin_fit_sdk.util import FIT_EPOCH_S, convert_timestamp_to_datetime
24-
25-
__version__ = '21.188.0'
1+
# __init__garmin_fit_sdk.py
2+
3+
###########################################################################################
4+
# Copyright 2026 Garmin International, Inc.
5+
# Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
6+
# may not use this file except in compliance with the Flexible and Interoperable Data
7+
# Transfer (FIT) Protocol License.
8+
###########################################################################################
9+
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
10+
# Profile Version = 21.194.0Release
11+
# Tag = production/release/21.194.0-0-g65135fc
12+
############################################################################################
13+
14+
15+
from garmin_fit_sdk.accumulator import Accumulator
16+
from garmin_fit_sdk.bitstream import BitStream
17+
from garmin_fit_sdk.crc_calculator import CrcCalculator
18+
from garmin_fit_sdk.decoder import Decoder
19+
from garmin_fit_sdk.fit import BASE_TYPE, BASE_TYPE_DEFINITIONS
20+
from garmin_fit_sdk.hr_mesg_utils import expand_heart_rates
21+
from garmin_fit_sdk.profile import Profile
22+
from garmin_fit_sdk.stream import Stream
23+
from garmin_fit_sdk.util import FIT_EPOCH_S, convert_timestamp_to_datetime
24+
25+
__version__ = '21.194.0'

garmin_fit_sdk/accumulator.py

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
'''accumulator.py: Contains the Accumulator class and sub-component class AccumulatedField'''
2-
3-
###########################################################################################
4-
# Copyright 2025 Garmin International, Inc.
5-
# Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
6-
# may not use this file except in compliance with the Flexible and Interoperable Data
7-
# Transfer (FIT) Protocol License.
8-
###########################################################################################
9-
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
10-
# Profile Version = 21.188.0Release
11-
# Tag = production/release/21.188.0-0-g55050f8
12-
############################################################################################
13-
14-
15-
class AccumulatedField:
16-
'''A class that accumulates a value for a particular field.
17-
Attributes:
18-
_accumulated_value: Resulting accumulated value
19-
_last_value: The previous accumulated value thus far.
20-
'''
21-
def __init__(self, value = 0):
22-
self._accumulated_value = value
23-
self._last_value = value
24-
25-
def accumulate(self, value, bits):
26-
''''Accumulates to the previous value and gives the updated accumulated value.'''
27-
mask = (1 << bits) - 1
28-
29-
self._accumulated_value += (value - self._last_value) & mask
30-
self._last_value = value
31-
32-
return self._accumulated_value
33-
34-
class Accumulator:
35-
'''A class that represents the accumulated values for particular fields.
36-
Attributes:
37-
_messages: A list of messages with a field or fields to accumulate.
38-
'''
39-
def __init__(self):
40-
self._messages = {}
41-
42-
def createAccumulatedField(self, mesg_num, field_num, value):
43-
'''Creates an accumulated field and stores its initial value in the accumulator'''
44-
accumulatedField = AccumulatedField(value)
45-
46-
if mesg_num not in self._messages:
47-
self._messages[mesg_num] = {}
48-
49-
self._messages[mesg_num][field_num] = accumulatedField
50-
51-
return accumulatedField
52-
53-
def accumulate(self, mesg_num, field_num, value, bits):
54-
'''Accumulates the given field value if present in the accumulator. If it is not, the accumulated field is added to the Accumulator.'''
55-
accumulatedField = None
56-
57-
if mesg_num in self._messages and field_num in self._messages[mesg_num]:
58-
accumulatedField = self._messages[mesg_num][field_num]
59-
else:
60-
accumulatedField = self.createAccumulatedField(mesg_num, field_num, value)
61-
62-
return accumulatedField.accumulate(value, bits)
63-
1+
'''accumulator.py: Contains the Accumulator class and sub-component class AccumulatedField'''
2+
3+
###########################################################################################
4+
# Copyright 2026 Garmin International, Inc.
5+
# Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
6+
# may not use this file except in compliance with the Flexible and Interoperable Data
7+
# Transfer (FIT) Protocol License.
8+
###########################################################################################
9+
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
10+
# Profile Version = 21.194.0Release
11+
# Tag = production/release/21.194.0-0-g65135fc
12+
############################################################################################
13+
14+
15+
class AccumulatedField:
16+
'''A class that accumulates a value for a particular field.
17+
Attributes:
18+
_accumulated_value: Resulting accumulated value
19+
_last_value: The previous accumulated value thus far.
20+
'''
21+
def __init__(self, value = 0):
22+
self._accumulated_value = value
23+
self._last_value = value
24+
25+
def accumulate(self, value, bits):
26+
''''Accumulates to the previous value and gives the updated accumulated value.'''
27+
mask = (1 << bits) - 1
28+
29+
self._accumulated_value += (value - self._last_value) & mask
30+
self._last_value = value
31+
32+
return self._accumulated_value
33+
34+
class Accumulator:
35+
'''A class that represents the accumulated values for particular fields.
36+
Attributes:
37+
_messages: A list of messages with a field or fields to accumulate.
38+
'''
39+
def __init__(self):
40+
self._messages = {}
41+
42+
def createAccumulatedField(self, mesg_num, field_num, value):
43+
'''Creates an accumulated field and stores its initial value in the accumulator'''
44+
accumulatedField = AccumulatedField(value)
45+
46+
if mesg_num not in self._messages:
47+
self._messages[mesg_num] = {}
48+
49+
self._messages[mesg_num][field_num] = accumulatedField
50+
51+
return accumulatedField
52+
53+
def accumulate(self, mesg_num, field_num, value, bits):
54+
'''Accumulates the given field value if present in the accumulator. If it is not, the accumulated field is added to the Accumulator.'''
55+
accumulatedField = None
56+
57+
if mesg_num in self._messages and field_num in self._messages[mesg_num]:
58+
accumulatedField = self._messages[mesg_num][field_num]
59+
else:
60+
accumulatedField = self.createAccumulatedField(mesg_num, field_num, value)
61+
62+
return accumulatedField.accumulate(value, bits)
63+

garmin_fit_sdk/bitstream.py

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
'''bitstream.py: Contains BitStream class which handles reading streams of data bit by bit '''
2-
3-
###########################################################################################
4-
# Copyright 2025 Garmin International, Inc.
5-
# Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
6-
# may not use this file except in compliance with the Flexible and Interoperable Data
7-
# Transfer (FIT) Protocol License.
8-
###########################################################################################
9-
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
10-
# Profile Version = 21.188.0Release
11-
# Tag = production/release/21.188.0-0-g55050f8
12-
############################################################################################
13-
14-
15-
from . import fit as FIT
16-
17-
18-
class BitStream:
19-
'''
20-
A class that represents a stream of binary data from a chunk of data.
21-
22-
Attributes:
23-
_array: The stream of data in an array structure.
24-
_current_array_position: Current position in data array.
25-
_bits_per_position: Number of bits per step through the data.
26-
_current_byte: Position of the current byte being read in the data.
27-
_current_bit: Position of the current bit being read in the data.
28-
_bits_available: Remaining number of bits left unread in the data.
29-
'''
30-
def __init__(self, data, base_type):
31-
self._array = None
32-
self._current_array_position = 0
33-
self._bits_per_position = 0
34-
self._current_byte = 0
35-
self._current_bit = 0
36-
self._bits_available = 0
37-
38-
self._array = data if isinstance(data, list) else [data]
39-
base_type_size = FIT.BASE_TYPE_DEFINITIONS[base_type]['size']
40-
self._bits_per_position = base_type_size * 8
41-
self.reset()
42-
43-
def bits_available(self):
44-
'''Returns the number of bits left in the data.'''
45-
return self._bits_available
46-
47-
def has_bits_available(self):
48-
'''Returns true if the data has bits available.'''
49-
return self._bits_available > 0
50-
51-
def reset(self):
52-
'''Resets the bitstream to the start of the data and resets the bits available.'''
53-
self._current_array_position = 0
54-
self._bits_available = self._bits_per_position * len(self._array)
55-
self.__next_byte()
56-
57-
def read_bit(self):
58-
'''Reads the next bit if possible.'''
59-
if self.has_bits_available() is False:
60-
self.__raise_error()
61-
62-
if self._current_bit >= self._bits_per_position:
63-
self.__next_byte()
64-
65-
bit = self._current_byte & 0x01
66-
self._current_byte = (self._current_byte >> 1)
67-
self._current_bit += 1
68-
self._bits_available -= 1
69-
70-
return bit
71-
72-
def read_bits(self, number_bits_to_read):
73-
'''Reads the specificed number of bits if possible.'''
74-
value = 0
75-
76-
for i in range(number_bits_to_read):
77-
value |= self.read_bit() << i
78-
79-
return value
80-
81-
def __next_byte(self):
82-
if self._current_array_position >= len(self._array):
83-
self.__raise_error()
84-
85-
self._current_byte = self._array[self._current_array_position]
86-
self._current_array_position += 1
87-
self._current_bit = 0
88-
89-
def __raise_error(self):
90-
raise IndexError('FIT Runtime Error, no bits available.')
1+
'''bitstream.py: Contains BitStream class which handles reading streams of data bit by bit '''
2+
3+
###########################################################################################
4+
# Copyright 2026 Garmin International, Inc.
5+
# Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
6+
# may not use this file except in compliance with the Flexible and Interoperable Data
7+
# Transfer (FIT) Protocol License.
8+
###########################################################################################
9+
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
10+
# Profile Version = 21.194.0Release
11+
# Tag = production/release/21.194.0-0-g65135fc
12+
############################################################################################
13+
14+
15+
from . import fit as FIT
16+
17+
18+
class BitStream:
19+
'''
20+
A class that represents a stream of binary data from a chunk of data.
21+
22+
Attributes:
23+
_array: The stream of data in an array structure.
24+
_current_array_position: Current position in data array.
25+
_bits_per_position: Number of bits per step through the data.
26+
_current_byte: Position of the current byte being read in the data.
27+
_current_bit: Position of the current bit being read in the data.
28+
_bits_available: Remaining number of bits left unread in the data.
29+
'''
30+
def __init__(self, data, base_type):
31+
self._array = None
32+
self._current_array_position = 0
33+
self._bits_per_position = 0
34+
self._current_byte = 0
35+
self._current_bit = 0
36+
self._bits_available = 0
37+
38+
self._array = data if isinstance(data, list) else [data]
39+
base_type_size = FIT.BASE_TYPE_DEFINITIONS[base_type]['size']
40+
self._bits_per_position = base_type_size * 8
41+
self.reset()
42+
43+
def bits_available(self):
44+
'''Returns the number of bits left in the data.'''
45+
return self._bits_available
46+
47+
def has_bits_available(self):
48+
'''Returns true if the data has bits available.'''
49+
return self._bits_available > 0
50+
51+
def reset(self):
52+
'''Resets the bitstream to the start of the data and resets the bits available.'''
53+
self._current_array_position = 0
54+
self._bits_available = self._bits_per_position * len(self._array)
55+
self.__next_byte()
56+
57+
def read_bit(self):
58+
'''Reads the next bit if possible.'''
59+
if self.has_bits_available() is False:
60+
self.__raise_error()
61+
62+
if self._current_bit >= self._bits_per_position:
63+
self.__next_byte()
64+
65+
bit = self._current_byte & 0x01
66+
self._current_byte = (self._current_byte >> 1)
67+
self._current_bit += 1
68+
self._bits_available -= 1
69+
70+
return bit
71+
72+
def read_bits(self, number_bits_to_read):
73+
'''Reads the specificed number of bits if possible.'''
74+
value = 0
75+
76+
for i in range(number_bits_to_read):
77+
value |= self.read_bit() << i
78+
79+
return value
80+
81+
def __next_byte(self):
82+
if self._current_array_position >= len(self._array):
83+
self.__raise_error()
84+
85+
self._current_byte = self._array[self._current_array_position]
86+
self._current_array_position += 1
87+
self._current_bit = 0
88+
89+
def __raise_error(self):
90+
raise IndexError('FIT Runtime Error, no bits available.')

0 commit comments

Comments
 (0)