rubyfit 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/rubyfit/fit.c +96 -25
- data/ext/rubyfit/fit.h +127 -44
- data/ext/rubyfit/fit_config.h +7 -7
- data/ext/rubyfit/fit_convert.c +66 -13
- data/ext/rubyfit/fit_convert.h +28 -23
- data/ext/rubyfit/fit_crc.c +30 -6
- data/ext/rubyfit/fit_crc.h +12 -5
- data/ext/rubyfit/fit_example.c +899 -0
- data/ext/rubyfit/fit_example.h +3299 -0
- data/ext/rubyfit/fit_ram.c +203 -0
- data/ext/rubyfit/fit_ram.h +39 -0
- data/ext/rubyfit/rubyfit.c +25 -36
- data/lib/rubyfit/version.rb +1 -1
- metadata +14 -16
- data/ext/rubyfit/fit_product.c +0 -21
- data/ext/rubyfit/fit_product.h +0 -21
- data/ext/rubyfit/fit_sdk.c +0 -618
- data/ext/rubyfit/fit_sdk.h +0 -2083
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64141f50e66fea97d5e3c78fbb7389f88b1276ef
|
4
|
+
data.tar.gz: 5b5fe0f8426a89efb7c386eb1a4a357f152108ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f519440065cf79423762fa2779b01e5a09b477370a8810e453461e5b4799a2e75a1ffbe295ec5e637bd2e3c7332d4b2c32f31be40a8ca3e8d9a29a2eb3e1750
|
7
|
+
data.tar.gz: 62f07c53fd8a423e316d2e23f3a26577e085fee98921bf421327d400abe2518ef1b318446742e093219490896b940ce514488ae361f5ee2f329488ae04075084
|
data/ext/rubyfit/fit.c
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
////////////////////////////////////////////////////////////////////////////////
|
2
|
-
// The following
|
3
|
-
// remains the copyrighted property of Dynastream Innovations Inc.
|
2
|
+
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
+
// devices only and remains the copyrighted property of Dynastream Innovations Inc.
|
4
4
|
// The software is being provided on an "as-is" basis and as an accommodation,
|
5
5
|
// and therefore all warranties, representations, or guarantees of any kind
|
6
6
|
// (whether express, implied or statutory) including, without limitation,
|
7
7
|
// warranties of merchantability, non-infringement, or fitness for a particular
|
8
8
|
// purpose, are specifically disclaimed.
|
9
9
|
//
|
10
|
-
// Copyright
|
11
|
-
// All rights reserved. This software may not be reproduced by any means
|
12
|
-
// without express written approval of Dynastream Innovations Inc.
|
10
|
+
// Copyright 2013 Dynastream Innovations Inc.
|
13
11
|
////////////////////////////////////////////////////////////////////////////////
|
12
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
+
// Profile Version = 8.10Release
|
14
|
+
// Tag = $Name: AKW8_100 $
|
15
|
+
// Product = EXAMPLE
|
16
|
+
// Alignment = 4 bytes, padding disabled.
|
17
|
+
////////////////////////////////////////////////////////////////////////////////
|
18
|
+
|
14
19
|
|
15
20
|
#include "string.h"
|
16
|
-
#include "
|
21
|
+
#include "fit.h"
|
22
|
+
#include "fit_example.h"
|
17
23
|
|
18
24
|
|
19
25
|
///////////////////////////////////////////////////////////////////////
|
@@ -53,22 +59,22 @@ const FIT_UINT16Z fit_uint16z_invalid = FIT_UINT16Z_INVALID;
|
|
53
59
|
const FIT_UINT32Z fit_uint32z_invalid = FIT_UINT32Z_INVALID;
|
54
60
|
const FIT_BYTE fit_byte_invalid = FIT_BYTE_INVALID;
|
55
61
|
|
56
|
-
const
|
62
|
+
const FIT_CONST_UINT8_PTR fit_base_type_invalids[FIT_BASE_TYPES] =
|
57
63
|
{
|
58
|
-
(
|
59
|
-
(
|
60
|
-
(
|
61
|
-
(
|
62
|
-
(
|
63
|
-
(
|
64
|
-
(
|
65
|
-
(
|
66
|
-
(
|
67
|
-
(
|
68
|
-
(
|
69
|
-
(
|
70
|
-
(
|
71
|
-
(
|
64
|
+
(FIT_CONST_UINT8_PTR)&fit_enum_invalid,
|
65
|
+
(FIT_CONST_UINT8_PTR)&fit_sint8_invalid,
|
66
|
+
(FIT_CONST_UINT8_PTR)&fit_uint8_invalid,
|
67
|
+
(FIT_CONST_UINT8_PTR)&fit_sint16_invalid,
|
68
|
+
(FIT_CONST_UINT8_PTR)&fit_uint16_invalid,
|
69
|
+
(FIT_CONST_UINT8_PTR)&fit_sint32_invalid,
|
70
|
+
(FIT_CONST_UINT8_PTR)&fit_uint32_invalid,
|
71
|
+
(FIT_CONST_UINT8_PTR)&fit_string_invalid,
|
72
|
+
(FIT_CONST_UINT8_PTR)&fit_float32_invalid,
|
73
|
+
(FIT_CONST_UINT8_PTR)&fit_float64_invalid,
|
74
|
+
(FIT_CONST_UINT8_PTR)&fit_uint8z_invalid,
|
75
|
+
(FIT_CONST_UINT8_PTR)&fit_uint16z_invalid,
|
76
|
+
(FIT_CONST_UINT8_PTR)&fit_uint32z_invalid,
|
77
|
+
(FIT_CONST_UINT8_PTR)&fit_byte_invalid,
|
72
78
|
};
|
73
79
|
|
74
80
|
|
@@ -82,7 +88,7 @@ FIT_UINT8 Fit_GetArch(void)
|
|
82
88
|
return (*(FIT_UINT8 *)&arch);
|
83
89
|
}
|
84
90
|
|
85
|
-
const FIT_MESG_DEF *Fit_GetMesgDef(
|
91
|
+
const FIT_MESG_DEF *Fit_GetMesgDef(FIT_UINT16 global_mesg_num)
|
86
92
|
{
|
87
93
|
FIT_UINT8 index;
|
88
94
|
|
@@ -103,7 +109,7 @@ FIT_UINT16 Fit_GetMesgDefSize(const FIT_MESG_DEF *mesg_def)
|
|
103
109
|
return FIT_STRUCT_OFFSET(fields, FIT_MESG_DEF) + (FIT_UINT16)mesg_def->num_fields * FIT_FIELD_DEF_SIZE;
|
104
110
|
}
|
105
111
|
|
106
|
-
FIT_UINT8 Fit_GetMesgSize(
|
112
|
+
FIT_UINT8 Fit_GetMesgSize(FIT_UINT16 global_mesg_num)
|
107
113
|
{
|
108
114
|
const FIT_MESG_DEF *mesg_def;
|
109
115
|
FIT_UINT8 field;
|
@@ -170,7 +176,33 @@ FIT_UINT8 Fit_GetFieldOffset(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_n
|
|
170
176
|
return FIT_UINT8_INVALID;
|
171
177
|
}
|
172
178
|
|
173
|
-
|
179
|
+
FIT_FIELD_DEF Fit_GetFieldDef(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num)
|
180
|
+
{
|
181
|
+
FIT_FIELD_DEF field_def;
|
182
|
+
const FIT_UINT8 *field_def_ptr = mesg_def->fields;
|
183
|
+
FIT_UINT8 field;
|
184
|
+
|
185
|
+
field_def.field_def_num = FIT_FIELD_NUM_INVALID;
|
186
|
+
|
187
|
+
if (mesg_def != FIT_NULL)
|
188
|
+
{
|
189
|
+
for (field = 0; field < mesg_def->num_fields; field++)
|
190
|
+
{
|
191
|
+
|
192
|
+
if (mesg_def->fields[FIT_MESG_DEF_FIELD_OFFSET(field_def_num, field)] == field_def_num)
|
193
|
+
{
|
194
|
+
memcpy(&field_def, field_def_ptr, FIT_FIELD_DEF_SIZE);
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
|
198
|
+
field_def_ptr += FIT_FIELD_DEF_SIZE;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
return field_def;
|
203
|
+
}
|
204
|
+
|
205
|
+
FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index, FIT_UINT32 *offset, FIT_READ_BYTES_FUNC read_bytes_func, FIT_BOOL read_header)
|
174
206
|
{
|
175
207
|
FIT_UINT16 global_mesg_nums[FIT_MAX_LOCAL_MESGS];
|
176
208
|
FIT_UINT8 sizes[FIT_MAX_LOCAL_MESGS];
|
@@ -181,6 +213,12 @@ FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index
|
|
181
213
|
FIT_UINT8 i;
|
182
214
|
|
183
215
|
*offset = 0;
|
216
|
+
|
217
|
+
if (read_header)
|
218
|
+
{
|
219
|
+
if(read_bytes_func(offset, FIT_STRUCT_OFFSET(header_size, FIT_FILE_HDR), sizeof(FIT_UINT8)) != sizeof(FIT_UINT8))
|
220
|
+
return FIT_UINT8_INVALID;
|
221
|
+
}
|
184
222
|
|
185
223
|
for (i = 0; i < FIT_MAX_LOCAL_MESGS; i++)
|
186
224
|
global_mesg_nums[i] = FIT_UINT16_INVALID;
|
@@ -220,7 +258,7 @@ FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index
|
|
220
258
|
return FIT_UINT8_INVALID;
|
221
259
|
|
222
260
|
#if defined(FIT_MESSAGE_INDEX)
|
223
|
-
if (field_def.field_def_num ==
|
261
|
+
if (field_def.field_def_num == FIT_FIELD_NUM_MESSAGE_INDEX)
|
224
262
|
current_message_index_offset = current_size;
|
225
263
|
#endif
|
226
264
|
|
@@ -279,3 +317,36 @@ FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index
|
|
279
317
|
}
|
280
318
|
}
|
281
319
|
}
|
320
|
+
|
321
|
+
FIT_UINT32 Fit_GetFileMesgOffset(const FIT_FILE_DEF *file_def, FIT_UINT16 mesg_num, FIT_UINT16 mesg_index)
|
322
|
+
{
|
323
|
+
FIT_UINT32 offset;
|
324
|
+
FIT_UINT16 i = 0;
|
325
|
+
|
326
|
+
while (i < file_def->mesg_count)
|
327
|
+
{
|
328
|
+
if (mesg_num == file_def->mesgs[i].num)
|
329
|
+
{
|
330
|
+
offset = file_def->mesgs[i].data_file_offset;
|
331
|
+
break;
|
332
|
+
}
|
333
|
+
|
334
|
+
i++;
|
335
|
+
}
|
336
|
+
|
337
|
+
if (i >= file_def->mesg_count)
|
338
|
+
return FIT_UINT32_INVALID;
|
339
|
+
|
340
|
+
// Make sure mesg_index is valid for this mesg num and file definition
|
341
|
+
if (mesg_index >= file_def->mesgs[i].count)
|
342
|
+
return FIT_UINT32_INVALID;
|
343
|
+
|
344
|
+
i = 1 + Fit_GetMesgSize(mesg_num); // Message header byte + data.
|
345
|
+
|
346
|
+
if (FIT_ALIGNMENT > FIT_HDR_SIZE)
|
347
|
+
i += FIT_ALIGNMENT - FIT_HDR_SIZE;
|
348
|
+
|
349
|
+
offset += mesg_index * i;
|
350
|
+
|
351
|
+
return offset;
|
352
|
+
}
|
data/ext/rubyfit/fit.h
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
////////////////////////////////////////////////////////////////////////////////
|
2
|
-
// The following
|
3
|
-
// remains the copyrighted property of Dynastream Innovations Inc.
|
2
|
+
// The following FIT Protocol software provided may be used with FIT protocol
|
3
|
+
// devices only and remains the copyrighted property of Dynastream Innovations Inc.
|
4
4
|
// The software is being provided on an "as-is" basis and as an accommodation,
|
5
5
|
// and therefore all warranties, representations, or guarantees of any kind
|
6
6
|
// (whether express, implied or statutory) including, without limitation,
|
7
7
|
// warranties of merchantability, non-infringement, or fitness for a particular
|
8
8
|
// purpose, are specifically disclaimed.
|
9
9
|
//
|
10
|
-
// Copyright
|
11
|
-
|
12
|
-
//
|
10
|
+
// Copyright 2013 Dynastream Innovations Inc.
|
11
|
+
////////////////////////////////////////////////////////////////////////////////
|
12
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
13
|
+
// Profile Version = 8.10Release
|
14
|
+
// Tag = $Name: AKW8_100 $
|
15
|
+
// Product = EXAMPLE
|
16
|
+
// Alignment = 4 bytes, padding disabled.
|
13
17
|
////////////////////////////////////////////////////////////////////////////////
|
14
18
|
|
15
19
|
|
@@ -18,6 +22,17 @@
|
|
18
22
|
|
19
23
|
#include "fit_config.h"
|
20
24
|
|
25
|
+
#if defined(FIT_USE_STDINT_H)
|
26
|
+
#include <stdint.h>
|
27
|
+
#else
|
28
|
+
typedef unsigned char uint8_t;
|
29
|
+
typedef signed char int8_t;
|
30
|
+
typedef unsigned short uint16_t;
|
31
|
+
typedef signed short int16_t;
|
32
|
+
typedef unsigned long uint32_t;
|
33
|
+
typedef signed long int32_t;
|
34
|
+
#endif
|
35
|
+
|
21
36
|
#if defined(__cplusplus)
|
22
37
|
extern "C" {
|
23
38
|
#endif
|
@@ -34,6 +49,11 @@
|
|
34
49
|
#define FIT_PROTOCOL_VERSION_MINOR_MASK ((FIT_UINT8) 0x0F)
|
35
50
|
#define FIT_PROTOCOL_VERSION ((FIT_UINT8) (FIT_PROTOCOL_VERSION_MAJOR << FIT_PROTOCOL_VERSION_MAJOR_SHIFT) | FIT_PROTOCOL_VERSION_MINOR)
|
36
51
|
|
52
|
+
#define FIT_PROFILE_VERSION_MAJOR 8
|
53
|
+
#define FIT_PROFILE_VERSION_MINOR 10
|
54
|
+
#define FIT_PROFILE_VERSION_SCALE 100
|
55
|
+
#define FIT_PROFILE_VERSION ((FIT_UINT16) (FIT_PROFILE_VERSION_MAJOR * 100 + FIT_PROFILE_VERSION_MINOR))
|
56
|
+
|
37
57
|
|
38
58
|
///////////////////////////////////////////////////////////////////////
|
39
59
|
// Type Definitions
|
@@ -45,60 +65,78 @@
|
|
45
65
|
#define FIT_BASE_TYPE_RESERVED ((FIT_UINT8)0x60)
|
46
66
|
#define FIT_BASE_TYPE_NUM_MASK ((FIT_UINT8)0x1F)
|
47
67
|
|
48
|
-
typedef
|
68
|
+
typedef uint8_t FIT_ENUM;
|
69
|
+
typedef const FIT_ENUM * FIT_CONST_ENUM_PTR;
|
49
70
|
#define FIT_ENUM_INVALID ((FIT_ENUM)0xFF)
|
50
71
|
#define FIT_BASE_TYPE_ENUM ((FIT_UINT8)0x00)
|
51
72
|
|
52
|
-
typedef
|
73
|
+
typedef int8_t FIT_SINT8;
|
74
|
+
typedef const FIT_SINT8 * FIT_CONST_SINT8_PTR;
|
53
75
|
#define FIT_SINT8_INVALID ((FIT_SINT8)0x7F)
|
54
76
|
#define FIT_BASE_TYPE_SINT8 ((FIT_UINT8)0x01)
|
55
77
|
|
56
|
-
typedef
|
78
|
+
typedef uint8_t FIT_UINT8;
|
79
|
+
typedef const FIT_UINT8 * FIT_CONST_UINT8_PTR;
|
57
80
|
#define FIT_UINT8_INVALID ((FIT_UINT8)0xFF)
|
58
81
|
#define FIT_BASE_TYPE_UINT8 ((FIT_UINT8)0x02)
|
59
82
|
|
60
|
-
typedef
|
83
|
+
typedef int16_t FIT_SINT16;
|
84
|
+
typedef const FIT_SINT16 * FIT_CONST_SINT16_PTR;
|
61
85
|
#define FIT_SINT16_INVALID ((FIT_SINT16)0x7FFF)
|
62
86
|
#define FIT_BASE_TYPE_SINT16 ((FIT_UINT8)0x83)
|
63
87
|
|
64
|
-
typedef
|
88
|
+
typedef uint16_t FIT_UINT16;
|
89
|
+
typedef const FIT_UINT16 * FIT_CONST_UINT16_PTR;
|
65
90
|
#define FIT_UINT16_INVALID ((FIT_UINT16)0xFFFF)
|
66
91
|
#define FIT_BASE_TYPE_UINT16 ((FIT_UINT8)0x84)
|
67
92
|
|
68
|
-
typedef
|
93
|
+
typedef int32_t FIT_SINT32;
|
94
|
+
typedef const FIT_SINT32 * FIT_CONST_SINT32_PTR;
|
69
95
|
#define FIT_SINT32_INVALID ((FIT_SINT32)0x7FFFFFFF)
|
70
96
|
#define FIT_BASE_TYPE_SINT32 ((FIT_UINT8)0x85)
|
71
97
|
|
72
|
-
typedef
|
98
|
+
typedef uint32_t FIT_UINT32;
|
99
|
+
typedef const FIT_UINT32 * FIT_CONST_UINT32_PTR;
|
73
100
|
#define FIT_UINT32_INVALID ((FIT_UINT32)0xFFFFFFFF)
|
74
101
|
#define FIT_BASE_TYPE_UINT32 ((FIT_UINT8)0x86)
|
75
102
|
|
76
|
-
typedef char FIT_STRING;
|
103
|
+
typedef char FIT_STRING; // UTF-8 null terminated string
|
104
|
+
typedef const FIT_STRING * FIT_CONST_STRING_PTR;
|
77
105
|
#define FIT_STRING_INVALID ((FIT_STRING)0x00)
|
78
106
|
#define FIT_BASE_TYPE_STRING ((FIT_UINT8)0x07)
|
79
107
|
|
80
108
|
typedef float FIT_FLOAT32;
|
109
|
+
typedef const FIT_FLOAT32 * FIT_CONST_FLOAT32_PTR;
|
81
110
|
#define FIT_FLOAT32_INVALID ((FIT_FLOAT32)0xFFFFFFFF)
|
82
111
|
#define FIT_BASE_TYPE_FLOAT32 ((FIT_UINT8)0x88)
|
83
112
|
|
84
113
|
typedef double FIT_FLOAT64;
|
85
|
-
|
114
|
+
typedef const FIT_FLOAT64 * FIT_CONST_FLOAT64_PTR;
|
115
|
+
#if defined (_BORLANDC_)
|
116
|
+
#define FIT_FLOAT64_INVALID ((FIT_FLOAT64)0xFFFFFFFFFFFFFFFFui64)
|
117
|
+
#else
|
118
|
+
#define FIT_FLOAT64_INVALID ((FIT_FLOAT64)0xFFFFFFFFFFFFFFFFull)
|
119
|
+
#endif
|
86
120
|
#define FIT_BASE_TYPE_FLOAT64 ((FIT_UINT8)0x89)
|
87
121
|
|
88
|
-
typedef
|
122
|
+
typedef uint8_t FIT_UINT8Z;
|
123
|
+
typedef const FIT_UINT8Z * FIT_CONST_UINT8Z_PTR;
|
89
124
|
#define FIT_UINT8Z_INVALID ((FIT_UINT8Z)0x00)
|
90
125
|
#define FIT_BASE_TYPE_UINT8Z ((FIT_UINT8)0x0A)
|
91
126
|
|
92
|
-
typedef
|
127
|
+
typedef uint16_t FIT_UINT16Z;
|
128
|
+
typedef const FIT_UINT16Z * FIT_CONST_UINT16Z_PTR;
|
93
129
|
#define FIT_UINT16Z_INVALID ((FIT_UINT16Z)0x0000)
|
94
130
|
#define FIT_BASE_TYPE_UINT16Z ((FIT_UINT8)0x8B)
|
95
131
|
|
96
|
-
typedef
|
132
|
+
typedef uint32_t FIT_UINT32Z;
|
133
|
+
typedef const FIT_UINT32Z * FIT_CONST_UINT32Z_PTR;
|
97
134
|
#define FIT_UINT32Z_INVALID ((FIT_UINT32Z)0x00000000)
|
98
135
|
#define FIT_BASE_TYPE_UINT32Z ((FIT_UINT8)0x8C)
|
99
136
|
|
100
|
-
typedef
|
101
|
-
|
137
|
+
typedef uint8_t FIT_BYTE;
|
138
|
+
typedef const FIT_BYTE * FIT_CONST_BYTE_PTR;
|
139
|
+
#define FIT_BYTE_INVALID ((FIT_BYTE)0xFF) // Field is invalid if all bytes are invalid.
|
102
140
|
#define FIT_BASE_TYPE_BYTE ((FIT_UINT8)0x0D)
|
103
141
|
|
104
142
|
#define FIT_BASE_TYPES 14
|
@@ -109,7 +147,7 @@ typedef FIT_ENUM FIT_BOOL;
|
|
109
147
|
#define FIT_BOOL_TRUE ((FIT_BOOL)1)
|
110
148
|
#define FIT_FALSE FIT_BOOL_FALSE
|
111
149
|
#define FIT_TRUE FIT_BOOL_TRUE
|
112
|
-
#define FIT_NULL
|
150
|
+
#define FIT_NULL 0
|
113
151
|
|
114
152
|
typedef FIT_UINT32 (*FIT_READ_BYTES_FUNC)(void *, FIT_UINT32, FIT_UINT32);
|
115
153
|
#define FIT_MESG_DEF_HEADER_SIZE FIT_STRUCT_OFFSET(fields, FIT_MESG_DEF)
|
@@ -123,19 +161,20 @@ typedef struct
|
|
123
161
|
{
|
124
162
|
FIT_UINT8 header_size; // FIT_FILE_HDR_SIZE (size of this structure)
|
125
163
|
FIT_UINT8 protocol_version; // FIT_PROTOCOL_VERSION
|
126
|
-
|
127
|
-
FIT_UINT8 profile_version_major; // FIT_PROFILE_VERSION_MAJOR
|
164
|
+
FIT_UINT16 profile_version; // FIT_PROFILE_VERSION
|
128
165
|
FIT_UINT32 data_size; // Does not include file header or crc. Little endian format.
|
129
166
|
FIT_UINT8 data_type[4]; // ".FIT"
|
167
|
+
FIT_UINT16 crc; // CRC of this file header in little endian format.
|
130
168
|
} FIT_FILE_HDR;
|
131
169
|
|
132
|
-
#define FIT_FILE_HDR_SIZE
|
170
|
+
#define FIT_FILE_HDR_SIZE 14
|
171
|
+
|
133
172
|
|
134
173
|
///////////////////////////////////////////////////////////////////////
|
135
174
|
// Record Definitions
|
136
175
|
///////////////////////////////////////////////////////////////////////
|
137
176
|
|
138
|
-
#define FIT_HDR_SIZE
|
177
|
+
#define FIT_HDR_SIZE 1
|
139
178
|
#define FIT_HDR_TIME_REC_BIT ((FIT_UINT8) 0x80)
|
140
179
|
#define FIT_HDR_TIME_TYPE_MASK ((FIT_UINT8) 0x60)
|
141
180
|
#define FIT_HDR_TIME_TYPE_SHIFT 5
|
@@ -144,6 +183,28 @@ typedef struct
|
|
144
183
|
#define FIT_HDR_TYPE_MASK ((FIT_UINT8) 0x0F)
|
145
184
|
#define FIT_MAX_LOCAL_MESGS (FIT_HDR_TYPE_MASK + 1)
|
146
185
|
|
186
|
+
///////////////////////////////////////////////////////////////////////
|
187
|
+
// File Definitions
|
188
|
+
///////////////////////////////////////////////////////////////////////
|
189
|
+
|
190
|
+
typedef struct
|
191
|
+
{
|
192
|
+
FIT_UINT32 def_file_offset;
|
193
|
+
FIT_UINT32 data_file_offset;
|
194
|
+
FIT_UINT16 num;
|
195
|
+
FIT_UINT16 count;
|
196
|
+
FIT_UINT16 mesg;
|
197
|
+
} FIT_FILE_MESG;
|
198
|
+
|
199
|
+
typedef struct
|
200
|
+
{
|
201
|
+
FIT_UINT32 data_size;
|
202
|
+
const FIT_FILE_MESG *mesgs;
|
203
|
+
FIT_UINT16 mesg_count;
|
204
|
+
FIT_UINT8 type;
|
205
|
+
FIT_UINT8 count;
|
206
|
+
} FIT_FILE_DEF;
|
207
|
+
|
147
208
|
|
148
209
|
///////////////////////////////////////////////////////////////////////
|
149
210
|
// Message Definitions
|
@@ -156,7 +217,7 @@ typedef struct
|
|
156
217
|
FIT_UINT8 base_type;
|
157
218
|
} FIT_FIELD_DEF;
|
158
219
|
|
159
|
-
#define FIT_FIELD_DEF_SIZE
|
220
|
+
#define FIT_FIELD_DEF_SIZE 3
|
160
221
|
|
161
222
|
typedef struct
|
162
223
|
{
|
@@ -170,8 +231,8 @@ typedef struct
|
|
170
231
|
#define FIT_MAX_MESG_SIZE ((FIT_UINT8)255)
|
171
232
|
|
172
233
|
#define FIT_ARCH_ENDIAN_MASK ((FIT_UINT8)0x01)
|
173
|
-
#define FIT_ARCH_ENDIAN_LITTLE
|
174
|
-
#define FIT_ARCH_ENDIAN_BIG
|
234
|
+
#define FIT_ARCH_ENDIAN_LITTLE 0
|
235
|
+
#define FIT_ARCH_ENDIAN_BIG 1
|
175
236
|
|
176
237
|
|
177
238
|
///////////////////////////////////////////////////////////////////////
|
@@ -180,18 +241,29 @@ typedef struct
|
|
180
241
|
|
181
242
|
#define FIT_MAX_FIELD_SIZE ((FIT_UINT8)255)
|
182
243
|
#define FIT_FIELD_NUM_INVALID ((FIT_UINT8)0xFF)
|
183
|
-
#define
|
184
|
-
#define
|
244
|
+
#define FIT_FIELD_NUM_MESSAGE_INDEX ((FIT_UINT8)254)
|
245
|
+
#define FIT_FIELD_NUM_TIMESTAMP ((FIT_UINT8)253)
|
246
|
+
|
247
|
+
#define FIT_MESSAGE_INDEX_FIELD_NUM FIT_FIELD_NUM_MESSAGE_INDEX // For reverse compatibility only. Use FIT_FIELD_NUM_MESSAGE_INDEX instead.
|
248
|
+
#define FIT_TIMESTAMP_FIELD_NUM FIT_FIELD_NUM_TIMESTAMP // For reverse compatibility only. Use FIT_FIELD_NUM_TIMESTAMP instead.
|
185
249
|
|
186
250
|
|
187
251
|
///////////////////////////////////////////////////////////////////////
|
188
252
|
// Macros
|
189
253
|
///////////////////////////////////////////////////////////////////////
|
190
254
|
|
191
|
-
#define FIT_STRUCT_OFFSET(MEMBER, STRUCT_TYPE)
|
192
|
-
|
193
|
-
#define
|
194
|
-
|
255
|
+
#define FIT_STRUCT_OFFSET(MEMBER, STRUCT_TYPE) ( ((FIT_UINT8 *) &(((STRUCT_TYPE *) FIT_NULL)->MEMBER)) - ((FIT_UINT8 *) (FIT_NULL)) ) // Computes the byte offset of a member in a file. Compiles to a constant.
|
256
|
+
|
257
|
+
#define FIT_MESG_DEF_FIELD_OFFSET(FIELD_MEMBER, FIELD_INDEX) (FIT_STRUCT_OFFSET(FIELD_MEMBER, FIT_FIELD_DEF) + FIT_FIELD_DEF_SIZE * FIELD_INDEX) // Computes the byte offset of a field definition member. Compiles to a constant.
|
258
|
+
|
259
|
+
// Offset of message in file including file header.
|
260
|
+
#define FIT_MESG_OFFSET(MESG_MEMBER, MESG_INDEX, MESG_SIZE, FILE) (FIT_STRUCT_OFFSET(MESG_MEMBER, FILE) + MESG_INDEX * (FIT_HDR_SIZE + MESG_SIZE) + FIT_HDR_SIZE) // Computes the byte offset of a message in a file structure. Compiles to a constant.
|
261
|
+
#define FIT_MESG_DEF_OFFSET(MESG_DEF_MEMBER, FILE) (FIT_STRUCT_OFFSET(MESG_DEF_MEMBER, FILE) + FIT_HDR_SIZE) // Computes the byte offset of a message definition in a file structure. Compiles to a constant.
|
262
|
+
|
263
|
+
// Below macros are obsolete because C file structures now include file header. For reverse compatibility only.
|
264
|
+
#define FIT_FILE_MESG_OFFSET(MESG_MEMBER, MESG_INDEX, MESG_SIZE, FILE) FIT_MESG_OFFSET(MESG_MEMBER, MESG_INDEX, MESG_SIZE, FILE)
|
265
|
+
#define FIT_FILE_MESG_DEF_OFFSET(MESG_DEF_MEMBER, FILE) FIT_MESG_DEF_OFFSET(MESG_DEF_MEMBER, FILE)
|
266
|
+
#define FIT_FILE_MESG_DEF_FIELD_OFFSET(FIELD_MEMBER, FIELD_INDEX) FIT_MESG_DEF_FIELD_OFFSET(FIELD_MEMBER, FIELD_INDEX)
|
195
267
|
|
196
268
|
|
197
269
|
///////////////////////////////////////////////////////////////////////
|
@@ -199,52 +271,63 @@ typedef struct
|
|
199
271
|
///////////////////////////////////////////////////////////////////////
|
200
272
|
|
201
273
|
const extern FIT_UINT8 fit_base_type_sizes[FIT_BASE_TYPES];
|
202
|
-
const extern
|
274
|
+
const extern FIT_CONST_UINT8_PTR fit_base_type_invalids[FIT_BASE_TYPES];
|
203
275
|
|
204
276
|
|
205
277
|
///////////////////////////////////////////////////////////////////////
|
206
278
|
// Public Functions
|
207
279
|
///////////////////////////////////////////////////////////////////////
|
208
280
|
|
209
|
-
FIT_UINT8 Fit_GetArch(void);
|
210
281
|
///////////////////////////////////////////////////////////////////////
|
211
282
|
// Returns architecture type.
|
212
283
|
// Includes runtime check for little or big endian.
|
213
284
|
// See FIT_MESG_DEF->arch and FIT_ARCH_*.
|
214
285
|
///////////////////////////////////////////////////////////////////////
|
286
|
+
FIT_UINT8 Fit_GetArch(void);
|
215
287
|
|
216
|
-
const FIT_MESG_DEF *Fit_GetMesgDef(FIT_UINT16 global_mesg_num);
|
217
288
|
///////////////////////////////////////////////////////////////////////
|
218
289
|
// Returns message definition corresponding to global message number.
|
219
290
|
///////////////////////////////////////////////////////////////////////
|
291
|
+
const FIT_MESG_DEF *Fit_GetMesgDef(FIT_UINT16 global_mesg_num);
|
220
292
|
|
221
|
-
FIT_UINT16 Fit_GetMesgDefSize(const FIT_MESG_DEF *mesg_def);
|
222
293
|
///////////////////////////////////////////////////////////////////////
|
223
294
|
// Returns the size of message definition.
|
224
295
|
///////////////////////////////////////////////////////////////////////
|
296
|
+
FIT_UINT16 Fit_GetMesgDefSize(const FIT_MESG_DEF *mesg_def);
|
225
297
|
|
226
|
-
FIT_UINT8 Fit_GetMesgSize(FIT_UINT16 global_mesg_num);
|
227
298
|
///////////////////////////////////////////////////////////////////////
|
228
299
|
// Returns the size of message corresponding to global message number.
|
229
300
|
///////////////////////////////////////////////////////////////////////
|
301
|
+
FIT_UINT8 Fit_GetMesgSize(FIT_UINT16 global_mesg_num);
|
230
302
|
|
231
|
-
FIT_BOOL Fit_InitMesg(const FIT_MESG_DEF *mesg_def, void *mesg);
|
232
303
|
///////////////////////////////////////////////////////////////////////
|
233
304
|
// Initializes message with invalids.
|
234
305
|
// Returns 1 if successful, otherwise 0.
|
235
306
|
///////////////////////////////////////////////////////////////////////
|
307
|
+
FIT_BOOL Fit_InitMesg(const FIT_MESG_DEF *mesg_def, void *mesg);
|
236
308
|
|
237
|
-
FIT_UINT8 Fit_GetFieldOffset(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num);
|
238
309
|
///////////////////////////////////////////////////////////////////////
|
239
310
|
// Returns the byte offset of a field in a message.
|
240
311
|
///////////////////////////////////////////////////////////////////////
|
312
|
+
FIT_UINT8 Fit_GetFieldOffset(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num);
|
313
|
+
|
314
|
+
///////////////////////////////////////////////////////////////////////
|
315
|
+
// Returns the definition for a field in a message.
|
316
|
+
// field_def_num is set to FIT_FIELD_NUM_INVALID if field is not found in message.
|
317
|
+
///////////////////////////////////////////////////////////////////////
|
318
|
+
FIT_FIELD_DEF Fit_GetFieldDef(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num);
|
319
|
+
|
320
|
+
///////////////////////////////////////////////////////////////////////
|
321
|
+
// Finds the byte offset of a message with the given message index in a FIT file
|
322
|
+
// Requires a pointer to a function which can read a given number of bytes from a provided offset in a FIT file.
|
323
|
+
// Returns the local message number if successful, or FIT_UINT8_INVALID if unsuccessful.
|
324
|
+
///////////////////////////////////////////////////////////////////////
|
325
|
+
FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index, FIT_UINT32 *offset, FIT_READ_BYTES_FUNC read_bytes_func, FIT_BOOL read_header);
|
241
326
|
|
242
|
-
FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index, FIT_UINT32 *offset, FIT_READ_BYTES_FUNC read_bytes_func);
|
243
327
|
///////////////////////////////////////////////////////////////////////
|
244
|
-
//
|
245
|
-
// Requires a pointer to a function which can read a given number of bytes from a provided offset in a .FIT file.
|
246
|
-
// Returns the local message number if successful, or FIT_UINT8 if unsuccessful.
|
328
|
+
// Returns the byte offset of a message within a file.
|
247
329
|
///////////////////////////////////////////////////////////////////////
|
330
|
+
FIT_UINT32 Fit_GetFileMesgOffset(const FIT_FILE_DEF *file_def, FIT_UINT16 mesg_num, FIT_UINT16 mesg_index);
|
248
331
|
|
249
332
|
#if defined(__cplusplus)
|
250
333
|
}
|