Skip to content

Commit 7980358

Browse files
pduraDavid Cooper
authored andcommitted
fix messages cache when multiple headers
1 parent 5c374ce commit 7980358

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

fitparse/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, fileish, check_crc=True, data_processor=None):
3030
self._file.seek(0, os.SEEK_END)
3131
self._filesize = self._file.tell()
3232
self._file.seek(0, os.SEEK_SET)
33+
self._messages = []
3334

3435
# Start off by parsing the file header (sets initial attribute values)
3536
self._parse_file_header()
@@ -98,7 +99,6 @@ def _parse_file_header(self):
9899
self._compressed_ts_accumulator = 0
99100
self._crc = Crc()
100101
self._local_mesgs = {}
101-
self._messages = []
102102

103103
header_data = self._read(12)
104104
if header_data[8:12] != b'.FIT':
79 KB
Binary file not shown.

tests/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ def test_elemnt_bolt_developer_data_id_without_application_id(self):
402402
(as seen on ELEMNT BOLT with firmware version WB09-1507)"""
403403
FitFile(testfile('elemnt-bolt-no-application-id-inside-developer-data-id.fit')).parse()
404404

405+
def test_multiple_header(self):
406+
f = FitFile(testfile('sample_mulitple_header.fit'))
407+
assert len(f.messages) == 3023
408+
409+
405410
# TODO:
406411
# * Test Processors:
407412
# - process_type_<>, process_field_<>, process_units_<>, process_message_<>

0 commit comments

Comments
 (0)