Skip to content

Commit 0b1dc79

Browse files
committed
FitFile._read_struct does not allow endian in fmt
Like before 5d8bb3a
1 parent 5d8bb3a commit 0b1dc79

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

fitparse/base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ def _read(self, size):
6565
return data
6666

6767
def _read_struct(self, fmt, endian='<', data=None, always_tuple=False):
68-
if fmt.startswith('<') or fmt.startswith('>'):
69-
# fmt contains endian
70-
fmt_with_endian = fmt
71-
else:
72-
fmt_with_endian = "%s%s" % (endian, fmt)
68+
fmt_with_endian = endian + fmt
7369
size = struct.calcsize(fmt_with_endian)
7470
if size <= 0:
7571
raise FitParseError("Invalid struct format: %s" % fmt_with_endian)

fitparse/records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ class Crc(object):
341341
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400,
342342
)
343343

344-
FMT = '<H'
344+
FMT = 'H'
345345

346346
def __init__(self, value=0, byte_arr=None):
347347
self.value = value

tests/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def generate_fitfile(data=None, endian='<'):
6464

6565
# Prototcol version 1.0, profile version 1.52
6666
header = pack('<2BHI4s', 14, 16, 152, len(fit_data), b'.FIT')
67-
file_data = header + pack(Crc.FMT, Crc.calculate(header)) + fit_data
68-
return file_data + pack(Crc.FMT, Crc.calculate(file_data))
67+
file_data = header + pack('<' + Crc.FMT, Crc.calculate(header)) + fit_data
68+
return file_data + pack('<' + Crc.FMT, Crc.calculate(file_data))
6969

7070

7171
def secs_to_dt(secs):

0 commit comments

Comments
 (0)